1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Star a note

This commit is contained in:
Dick Choi
2016-05-29 13:08:02 +09:00
parent eb210e9072
commit 5a26fc812d
7 changed files with 205 additions and 4 deletions

View File

@@ -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
}
}