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

Add unpin

This commit is contained in:
asmsuechan
2017-10-11 13:31:40 +09:00
parent fe8045c51d
commit 8fd4deb3eb
2 changed files with 22 additions and 4 deletions

View File

@@ -292,8 +292,9 @@ class NoteList extends React.Component {
if (storage == null) return []
let folder = _.find(storage.folders, {key: folderKey})
if (folder === undefined) return unorderedNotes
const pinnedNotes = unorderedNotes.filter((el) => {
return folder.pinnedNotes && folder.pinnedNotes.includes(el.key)
return el.isPinned
})
return pinnedNotes.concat(unorderedNotes)
@@ -430,9 +431,16 @@ class NoteList extends React.Component {
}
handleNoteContextMenu (e, uniqueKey) {
let targetIndex = _.findIndex(this.notes, (note) => {
return note != null && uniqueKey === `${note.storage}-${note.key}`
})
let note = this.notes[targetIndex]
console.log(note)
const label = note.isPinned ? 'Remove pin' : 'Pin to Top'
let menu = new Menu()
menu.append(new MenuItem({
label: 'Pin to Top',
label: label,
click: (e) => this.handlePinToTop(e, uniqueKey)
}))
menu.popup()
@@ -464,14 +472,20 @@ class NoteList extends React.Component {
})
let targetIndex = _.findIndex(this.notes, (note) => {
return note != null && note.storage + '-' + note.key === location.query.key
return note != null && note.storage + '-' + note.key === uniqueKey
})
let note = this.notes[targetIndex]
if (note.isPinned) {
note.isPinned = false
console.log('unpinned')
} else {
note.isPinned = true
console.log('pinned')
}
dataApi
.updateNote(note.storage, note.key, note)
.then((note) => {
note.isPinned = true
store.dispatch({
type: 'UPDATE_NOTE',
note: note