mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
update tagNoteMap when delete / restore the notebook
deleted note should not belong to tagNoteMap
This commit is contained in:
@@ -88,9 +88,27 @@ function data (state = defaultDataMap(), action) {
|
||||
if (note.isTrashed) {
|
||||
state.trashedSet.add(uniqueKey)
|
||||
state.starredSet.delete(uniqueKey)
|
||||
|
||||
note.tags.forEach(tag => {
|
||||
let tagNoteList = state.tagNoteMap.get(tag)
|
||||
if (tagNoteList != null) {
|
||||
tagNoteList = new Set(tagNoteList)
|
||||
tagNoteList.delete(uniqueKey)
|
||||
state.tagNoteMap.set(tag, tagNoteList)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
state.trashedSet.delete(uniqueKey)
|
||||
|
||||
note.tags.forEach(tag => {
|
||||
let tagNoteList = state.tagNoteMap.get(tag)
|
||||
if (tagNoteList != null) {
|
||||
tagNoteList = new Set(tagNoteList)
|
||||
tagNoteList.add(uniqueKey)
|
||||
state.tagNoteMap.set(tag, tagNoteList)
|
||||
}
|
||||
})
|
||||
|
||||
if (note.isStarred) {
|
||||
state.starredSet.add(uniqueKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user