mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
prevent duplication of starred
This commit is contained in:
@@ -446,6 +446,7 @@ class Repository {
|
|||||||
if (note != null) {
|
if (note != null) {
|
||||||
let json = this.json
|
let json = this.json
|
||||||
json.starred.push(noteKey)
|
json.starred.push(noteKey)
|
||||||
|
json.starred = _.uniq(json.starred)
|
||||||
|
|
||||||
return this.saveJSON(json)
|
return this.saveJSON(json)
|
||||||
}
|
}
|
||||||
@@ -457,6 +458,7 @@ class Repository {
|
|||||||
let json = this.json
|
let json = this.json
|
||||||
json.starred = json.starred
|
json.starred = json.starred
|
||||||
.filter((starredKey) => starredKey !== noteKey)
|
.filter((starredKey) => starredKey !== noteKey)
|
||||||
|
json.starred = _.uniq(json.starred)
|
||||||
|
|
||||||
return this.saveJSON(json)
|
return this.saveJSON(json)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ function repositories (state = initialRepositories, action) {
|
|||||||
let targetNoteIndex = _.findIndex(targetRepo.notes, {key: action.note})
|
let targetNoteIndex = _.findIndex(targetRepo.notes, {key: action.note})
|
||||||
if (targetNoteIndex > -1) {
|
if (targetNoteIndex > -1) {
|
||||||
targetRepo.starred.push(action.note)
|
targetRepo.starred.push(action.note)
|
||||||
|
targetRepo.starred = _.uniq(targetRepo.starred)
|
||||||
} else {
|
} else {
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
@@ -159,6 +160,7 @@ function repositories (state = initialRepositories, action) {
|
|||||||
|
|
||||||
targetRepo.starred = targetRepo.starred
|
targetRepo.starred = targetRepo.starred
|
||||||
.filter((starredKey) => starredKey !== action.note)
|
.filter((starredKey) => starredKey !== action.note)
|
||||||
|
targetRepo.starred = _.uniq(targetRepo.starred)
|
||||||
|
|
||||||
return repos
|
return repos
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user