mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Star a note
This commit is contained in:
@@ -132,6 +132,34 @@ function repositories (state = initialRepositories, action) {
|
||||
targetRepo.notes.push(action.note)
|
||||
}
|
||||
|
||||
return repos
|
||||
}
|
||||
case 'STAR_NOTE':
|
||||
{
|
||||
let repos = state.slice()
|
||||
let targetRepo = _.find(repos, {key: action.repository})
|
||||
|
||||
if (targetRepo == null) return state
|
||||
|
||||
let targetNoteIndex = _.findIndex(targetRepo.notes, {key: action.note})
|
||||
if (targetNoteIndex > -1) {
|
||||
targetRepo.starred.push(action.note)
|
||||
} else {
|
||||
return state
|
||||
}
|
||||
|
||||
return repos
|
||||
}
|
||||
case 'UNSTAR_NOTE':
|
||||
{
|
||||
let repos = state.slice()
|
||||
let targetRepo = _.find(repos, {key: action.repository})
|
||||
|
||||
if (targetRepo == null) return state
|
||||
|
||||
targetRepo.starred = targetRepo.starred
|
||||
.filter((starredKey) => starredKey !== action.note)
|
||||
|
||||
return repos
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user