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

debug on saving data & error throw if dataStore get wrong data

This commit is contained in:
Rokt33r
2015-12-28 18:29:48 +09:00
parent 5cfc418d77
commit 48fcd45d7d
2 changed files with 5 additions and 3 deletions

View File

@@ -110,12 +110,14 @@ export function getData () {
} }
export function setArticles (articles) { export function setArticles (articles) {
if (!_.isArray(articles)) throw new Error('Articles must be an array')
let data = getData() let data = getData()
data.articles = articles data.articles = articles
jetpack.write(getLocalPath(), data) jetpack.write(getLocalPath(), data)
} }
export function setFolders (folders) { export function setFolders (folders) {
if (!_.isArray(folders)) throw new Error('Folders must be an array')
let data = getData() let data = getData()
data.folders = folders data.folders = folders
jetpack.write(getLocalPath(), data) jetpack.write(getLocalPath(), data)

View File

@@ -226,16 +226,16 @@ function articles (state = initialArticles, action) {
let modifiedIndex = _.findIndex(state.modified, _article => articleKey === _article.key) let modifiedIndex = _.findIndex(state.modified, _article => articleKey === _article.key)
if (modifiedIndex >= 0) state.modified.splice(modifiedIndex, 1) if (modifiedIndex >= 0) state.modified.splice(modifiedIndex, 1)
dataStore.setArticles(state) dataStore.setArticles(state.data)
return state return state
} }
case FOLDER_DESTROY: case FOLDER_DESTROY:
{ {
let folderKey = action.data.key let folderKey = action.data.key
state = state.filter(article => article.FolderKey !== folderKey) state.data = state.data.filter(article => article.FolderKey !== folderKey)
dataStore.setArticles(state) dataStore.setArticles(state.data)
return state return state
} }
default: default: