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

add Folder

This commit is contained in:
Rokt33r
2016-05-03 22:38:54 +09:00
parent df51e6d429
commit dcf773fd88
7 changed files with 197 additions and 40 deletions

View File

@@ -35,16 +35,36 @@ function repositories (state = initialRepositories, action) {
case 'ADD_REPOSITORY':
{
let repos = state.slice()
repos.push(action.repository)
return repos
}
case 'REMOVE_REPOSITORY':
{
let repos = state.slice()
let targetIndex = _.findIndex(repos, {key: action.key})
if (targetIndex > -1) {
repos.splice(targetIndex, 1)
}
return repos
}
case 'ADD_FOLDER':
{
let repos = state.slice()
let targetRepo = _.find(repos, {key: action.key})
if (targetRepo == null) return state
let targetFolderIndex = _.findIndex(targetRepo.folders, {key: action.folder.key})
if (targetFolderIndex < 0) {
targetRepo.folders.push(action.folder)
} else {
targetRepo.folders.splice(targetFolderIndex, 1, action.folder)
}
return repos
}
}