1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 10:16:26 +00:00

fix delete and empty trash

This commit is contained in:
mirsch
2018-03-04 23:28:18 +01:00
parent 0280a5f09e
commit fa2d34dcfc
3 changed files with 7 additions and 11 deletions

View File

@@ -548,11 +548,9 @@ class NoteList extends React.Component {
}) })
if (dialogueButtonIndex === 1) return if (dialogueButtonIndex === 1) return
Promise.all( Promise.all(
selectedNoteKeys.map((uniqueKey) => { selectedNotes.map((note) => {
const storageKey = uniqueKey.split('-')[0]
const noteKey = uniqueKey.split('-')[1]
return dataApi return dataApi
.deleteNote(storageKey, noteKey) .deleteNote(note.storage, note.key)
}) })
) )
.then((data) => { .then((data) => {

View File

@@ -148,10 +148,8 @@ class SideNav extends React.Component {
emptyTrash (entries) { emptyTrash (entries) {
const { dispatch } = this.props const { dispatch } = this.props
const deletionPromises = entries.map((storageAndNoteKey) => { const deletionPromises = entries.map((note) => {
const storageKey = storageAndNoteKey.split('-')[0] return dataApi.deleteNote(note.storage, note.key)
const noteKey = storageAndNoteKey.split('-')[1]
return dataApi.deleteNote(storageKey, noteKey)
}) })
Promise.all(deletionPromises) Promise.all(deletionPromises)
.then((arrayOfStorageAndNoteKeys) => { .then((arrayOfStorageAndNoteKeys) => {
@@ -167,9 +165,9 @@ class SideNav extends React.Component {
handleFilterButtonContextMenu (event) { handleFilterButtonContextMenu (event) {
const { data } = this.props const { data } = this.props
const entries = data.trashedSet.toJS() const trashedNotes = data.trashedSet.toJS().map((uniqueKey) => data.noteMap.get(uniqueKey))
const menu = Menu.buildFromTemplate([ const menu = Menu.buildFromTemplate([
{ label: 'Empty Trash', click: () => this.emptyTrash(entries) } { label: 'Empty Trash', click: () => this.emptyTrash(trashedNotes) }
]) ])
menu.popup() menu.popup()
} }

View File

@@ -297,7 +297,7 @@ function data (state = defaultDataMap(), action) {
} }
case 'DELETE_NOTE': case 'DELETE_NOTE':
{ {
const uniqueKey = action.storageKey + '-' + action.noteKey const uniqueKey = action.noteKey
const targetNote = state.noteMap.get(uniqueKey) const targetNote = state.noteMap.get(uniqueKey)
state = Object.assign({}, state) state = Object.assign({}, state)