mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Add unpin
This commit is contained in:
@@ -292,8 +292,9 @@ class NoteList extends React.Component {
|
|||||||
if (storage == null) return []
|
if (storage == null) return []
|
||||||
|
|
||||||
let folder = _.find(storage.folders, {key: folderKey})
|
let folder = _.find(storage.folders, {key: folderKey})
|
||||||
|
if (folder === undefined) return unorderedNotes
|
||||||
const pinnedNotes = unorderedNotes.filter((el) => {
|
const pinnedNotes = unorderedNotes.filter((el) => {
|
||||||
return folder.pinnedNotes && folder.pinnedNotes.includes(el.key)
|
return el.isPinned
|
||||||
})
|
})
|
||||||
|
|
||||||
return pinnedNotes.concat(unorderedNotes)
|
return pinnedNotes.concat(unorderedNotes)
|
||||||
@@ -430,9 +431,16 @@ class NoteList extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleNoteContextMenu (e, uniqueKey) {
|
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()
|
let menu = new Menu()
|
||||||
menu.append(new MenuItem({
|
menu.append(new MenuItem({
|
||||||
label: 'Pin to Top',
|
label: label,
|
||||||
click: (e) => this.handlePinToTop(e, uniqueKey)
|
click: (e) => this.handlePinToTop(e, uniqueKey)
|
||||||
}))
|
}))
|
||||||
menu.popup()
|
menu.popup()
|
||||||
@@ -464,14 +472,20 @@ class NoteList extends React.Component {
|
|||||||
})
|
})
|
||||||
|
|
||||||
let targetIndex = _.findIndex(this.notes, (note) => {
|
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]
|
let note = this.notes[targetIndex]
|
||||||
|
if (note.isPinned) {
|
||||||
|
note.isPinned = false
|
||||||
|
console.log('unpinned')
|
||||||
|
} else {
|
||||||
|
note.isPinned = true
|
||||||
|
console.log('pinned')
|
||||||
|
}
|
||||||
|
|
||||||
dataApi
|
dataApi
|
||||||
.updateNote(note.storage, note.key, note)
|
.updateNote(note.storage, note.key, note)
|
||||||
.then((note) => {
|
.then((note) => {
|
||||||
note.isPinned = true
|
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'UPDATE_NOTE',
|
type: 'UPDATE_NOTE',
|
||||||
note: note
|
note: note
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ function validateInput (input) {
|
|||||||
validatedInput.isTrashed = !!input.isTrashed
|
validatedInput.isTrashed = !!input.isTrashed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (input.isPinned !== undefined) {
|
||||||
|
validatedInput.isPinned = !!input.isPinned
|
||||||
|
}
|
||||||
|
|
||||||
validatedInput.type = input.type
|
validatedInput.type = input.type
|
||||||
switch (input.type) {
|
switch (input.type) {
|
||||||
case 'MARKDOWN_NOTE':
|
case 'MARKDOWN_NOTE':
|
||||||
|
|||||||
Reference in New Issue
Block a user