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:
@@ -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)
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user