1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

feat: add multiple pin to top and rename activateNote to focusNote

This commit is contained in:
voidSatisfaction
2017-11-06 21:53:31 +09:00
parent bcb1fb4331
commit 9139495f02

View File

@@ -53,8 +53,9 @@ class NoteList extends React.Component {
this.jumpNoteByHash = this.jumpNoteByHashHandler.bind(this) this.jumpNoteByHash = this.jumpNoteByHashHandler.bind(this)
this.handleNoteListKeyUp = this.handleNoteListKeyUp.bind(this) this.handleNoteListKeyUp = this.handleNoteListKeyUp.bind(this)
this.deleteNote = this.deleteNote.bind(this) this.deleteNote = this.deleteNote.bind(this)
this.activateNote = this.activateNote.bind(this) this.focusNote = this.focusNote.bind(this)
// TODO: not Selected noteKeys but SelectedNote(for reusing)
this.state = { this.state = {
shiftKeyDown: false, shiftKeyDown: false,
selectedNoteKeys: [] selectedNoteKeys: []
@@ -130,7 +131,7 @@ class NoteList extends React.Component {
} }
} }
activateNote (selectedNoteKeys, noteKey) { focusNote (selectedNoteKeys, noteKey) {
let { router } = this.context let { router } = this.context
let { location } = this.props let { location } = this.props
@@ -166,7 +167,7 @@ class NoteList extends React.Component {
const priorNoteKey = `${priorNote.storage}-${priorNote.key}` const priorNoteKey = `${priorNote.storage}-${priorNote.key}`
selectedNoteKeys.push(priorNoteKey) selectedNoteKeys.push(priorNoteKey)
this.activateNote(selectedNoteKeys, priorNoteKey) this.focusNote(selectedNoteKeys, priorNoteKey)
} }
selectNextNote () { selectNextNote () {
@@ -192,7 +193,7 @@ class NoteList extends React.Component {
const nextNoteKey = `${nextNote.storage}-${nextNote.key}` const nextNoteKey = `${nextNote.storage}-${nextNote.key}`
selectedNoteKeys.push(nextNoteKey) selectedNoteKeys.push(nextNoteKey)
this.activateNote(selectedNoteKeys, nextNoteKey) this.focusNote(selectedNoteKeys, nextNoteKey)
ee.emit('list:moved') ee.emit('list:moved')
} }
@@ -215,7 +216,7 @@ class NoteList extends React.Component {
const nextNoteKey = `${nextNote.storage}-${nextNote.key}` const nextNoteKey = `${nextNote.storage}-${nextNote.key}`
selectedNoteKeys.push(nextNoteKey) selectedNoteKeys.push(nextNoteKey)
this.activateNote(selectedNoteKeys, nextNoteKey) this.focusNote(selectedNoteKeys, nextNoteKey)
ee.emit('list:moved') ee.emit('list:moved')
} }
@@ -439,26 +440,27 @@ class NoteList extends React.Component {
} }
pinToTop (e, uniqueKey) { pinToTop (e, uniqueKey) {
const { data, params } = this.props const { selectedNoteKeys } = this.state
const storageKey = params.storageKey const { dispatch } = this.props
const folderKey = params.folderKey const notes = this.notes.map((note) => Object.assign({}, note))
const selectedNotes = notes.filter((note) => selectedNoteKeys.includes(`${note.storage}-${note.key}`))
const currentStorage = data.storageMap.get(storageKey) Promise.all(
const currentFolder = _.find(currentStorage.folders, {key: folderKey}) selectedNotes.map((note) => {
note.isPinned = !note.isPinned
this.handleNoteClick(e, uniqueKey) return dataApi
const targetIndex = this.getTargetIndex() .updateNote(note.storage, note.key, note)
let note = this.notes[targetIndex] })
note.isPinned = !note.isPinned )
.then((updatedNotes) => {
dataApi updatedNotes.forEach((note) => {
.updateNote(note.storage, note.key, note) dispatch({
.then((note) => {
store.dispatch({
type: 'UPDATE_NOTE', type: 'UPDATE_NOTE',
note: note note
}) })
}) })
})
this.setState({ selectedNoteKeys: [] })
} }
deleteNote () { deleteNote () {