Skip to content

Commit 431ac5a

Browse files
committed
prevent duplication of starred
1 parent 999d463 commit 431ac5a

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

browser/lib/Repository.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ class Repository {
446446
if (note != null) {
447447
let json = this.json
448448
json.starred.push(noteKey)
449+
json.starred = _.uniq(json.starred)
449450

450451
return this.saveJSON(json)
451452
}
@@ -457,6 +458,7 @@ class Repository {
457458
let json = this.json
458459
json.starred = json.starred
459460
.filter((starredKey) => starredKey !== noteKey)
461+
json.starred = _.uniq(json.starred)
460462

461463
return this.saveJSON(json)
462464
}

browser/main/store.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ function repositories (state = initialRepositories, action) {
144144
let targetNoteIndex = _.findIndex(targetRepo.notes, {key: action.note})
145145
if (targetNoteIndex > -1) {
146146
targetRepo.starred.push(action.note)
147+
targetRepo.starred = _.uniq(targetRepo.starred)
147148
} else {
148149
return state
149150
}
@@ -159,6 +160,7 @@ function repositories (state = initialRepositories, action) {
159160

160161
targetRepo.starred = targetRepo.starred
161162
.filter((starredKey) => starredKey !== action.note)
163+
targetRepo.starred = _.uniq(targetRepo.starred)
162164

163165
return repos
164166
}

0 commit comments

Comments
 (0)