mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 10:46:32 +00:00
Refactoring changing of "starred"
This commit is contained in:
@@ -58,14 +58,7 @@ function data (state = defaultDataMap(), action) {
|
|||||||
state.noteMap = new Map(state.noteMap)
|
state.noteMap = new Map(state.noteMap)
|
||||||
state.noteMap.set(uniqueKey, note)
|
state.noteMap.set(uniqueKey, note)
|
||||||
|
|
||||||
if (oldNote == null || oldNote.isStarred !== note.isStarred) {
|
updateStarredChange(oldNote, note, state, uniqueKey)
|
||||||
state.starredSet = new Set(state.starredSet)
|
|
||||||
if (note.isStarred) {
|
|
||||||
state.starredSet.add(uniqueKey)
|
|
||||||
} else {
|
|
||||||
state.starredSet.delete(uniqueKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldNote == null || oldNote.isTrashed !== note.isTrashed) {
|
if (oldNote == null || oldNote.isTrashed !== note.isTrashed) {
|
||||||
state.trashedSet = new Set(state.trashedSet)
|
state.trashedSet = new Set(state.trashedSet)
|
||||||
@@ -164,14 +157,7 @@ function data (state = defaultDataMap(), action) {
|
|||||||
removeFromTags(originNote.tags, state, originKey)
|
removeFromTags(originNote.tags, state, originKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldNote == null || oldNote.isStarred !== note.isStarred) {
|
updateStarredChange(oldNote, note, state, uniqueKey)
|
||||||
state.starredSet = new Set(state.starredSet)
|
|
||||||
if (note.isStarred) {
|
|
||||||
state.starredSet.add(uniqueKey)
|
|
||||||
} else {
|
|
||||||
state.starredSet.delete(uniqueKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldNote == null || oldNote.isTrashed !== note.isTrashed) {
|
if (oldNote == null || oldNote.isTrashed !== note.isTrashed) {
|
||||||
state.trashedSet = new Set(state.trashedSet)
|
state.trashedSet = new Set(state.trashedSet)
|
||||||
@@ -444,6 +430,17 @@ function status (state = defaultStatus, action) {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateStarredChange (oldNote, note, state, uniqueKey) {
|
||||||
|
if (oldNote == null || oldNote.isStarred !== note.isStarred) {
|
||||||
|
state.starredSet = new Set(state.starredSet)
|
||||||
|
if (note.isStarred) {
|
||||||
|
state.starredSet.add(uniqueKey)
|
||||||
|
} else {
|
||||||
|
state.starredSet.delete(uniqueKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateTagChanges (oldNote, note, state, uniqueKey) {
|
function updateTagChanges (oldNote, note, state, uniqueKey) {
|
||||||
const discardedTags = _.difference(oldNote.tags, note.tags)
|
const discardedTags = _.difference(oldNote.tags, note.tags)
|
||||||
const addedTags = _.difference(note.tags, oldNote.tags)
|
const addedTags = _.difference(note.tags, oldNote.tags)
|
||||||
|
|||||||
Reference in New Issue
Block a user