mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
add uncacheArticle, uncacheAllArticles action
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
// Action types
|
// Action types
|
||||||
export const USER_UPDATE = 'USER_UPDATE'
|
export const USER_UPDATE = 'USER_UPDATE'
|
||||||
|
|
||||||
export const CLEAR_NEW_ARTICLE = 'CLEAR_NEW_ARTICLE'
|
|
||||||
export const ARTICLE_UPDATE = 'ARTICLE_UPDATE'
|
export const ARTICLE_UPDATE = 'ARTICLE_UPDATE'
|
||||||
export const ARTICLE_DESTROY = 'ARTICLE_DESTROY'
|
export const ARTICLE_DESTROY = 'ARTICLE_DESTROY'
|
||||||
export const ARTICLE_SAVE = 'ARTICLE_SAVE'
|
export const ARTICLE_SAVE = 'ARTICLE_SAVE'
|
||||||
export const ARTICLE_SAVE_ALL = 'ARTICLE_SAVE_ALL'
|
export const ARTICLE_SAVE_ALL = 'ARTICLE_SAVE_ALL'
|
||||||
export const ARTICLE_CACHE = 'ARTICLE_CACHE'
|
export const ARTICLE_CACHE = 'ARTICLE_CACHE'
|
||||||
|
export const ARTICLE_UNCACHE = 'ARTICLE_UNCACHE'
|
||||||
|
export const ARTICLE_UNCACHE_ALL = 'ARTICLE_UNCACHE_ALL'
|
||||||
|
|
||||||
export const FOLDER_CREATE = 'FOLDER_CREATE'
|
export const FOLDER_CREATE = 'FOLDER_CREATE'
|
||||||
export const FOLDER_UPDATE = 'FOLDER_UPDATE'
|
export const FOLDER_UPDATE = 'FOLDER_UPDATE'
|
||||||
export const FOLDER_DESTROY = 'FOLDER_DESTROY'
|
export const FOLDER_DESTROY = 'FOLDER_DESTROY'
|
||||||
@@ -31,12 +33,6 @@ export function updateUser (input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
export function clearNewArticle () {
|
|
||||||
return {
|
|
||||||
type: CLEAR_NEW_ARTICLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function cacheArticle (key, article) {
|
export function cacheArticle (key, article) {
|
||||||
return {
|
return {
|
||||||
type: ARTICLE_CACHE,
|
type: ARTICLE_CACHE,
|
||||||
@@ -44,6 +40,19 @@ export function cacheArticle (key, article) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function uncacheArticle (key) {
|
||||||
|
return {
|
||||||
|
type: ARTICLE_UNCACHE,
|
||||||
|
data: { key }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function uncacheAllArticles () {
|
||||||
|
return {
|
||||||
|
type: ARTICLE_UNCACHE_ALL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function saveArticle (key, article, forceSwitch) {
|
export function saveArticle (key, article, forceSwitch) {
|
||||||
return {
|
return {
|
||||||
type: ARTICLE_SAVE,
|
type: ARTICLE_SAVE,
|
||||||
@@ -147,10 +156,11 @@ export function toggleTutorial () {
|
|||||||
export default {
|
export default {
|
||||||
updateUser,
|
updateUser,
|
||||||
|
|
||||||
clearNewArticle,
|
|
||||||
updateArticle,
|
updateArticle,
|
||||||
destroyArticle,
|
destroyArticle,
|
||||||
cacheArticle,
|
cacheArticle,
|
||||||
|
uncacheArticle,
|
||||||
|
uncacheAllArticles,
|
||||||
saveArticle,
|
saveArticle,
|
||||||
saveAllArticles,
|
saveAllArticles,
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import {
|
|||||||
ARTICLE_UPDATE,
|
ARTICLE_UPDATE,
|
||||||
ARTICLE_DESTROY,
|
ARTICLE_DESTROY,
|
||||||
ARTICLE_CACHE,
|
ARTICLE_CACHE,
|
||||||
|
ARTICLE_UNCACHE,
|
||||||
|
ARTICLE_UNCACHE_ALL,
|
||||||
ARTICLE_SAVE,
|
ARTICLE_SAVE,
|
||||||
ARTICLE_SAVE_ALL,
|
ARTICLE_SAVE_ALL,
|
||||||
|
|
||||||
@@ -169,6 +171,16 @@ function articles (state = initialArticles, action) {
|
|||||||
else Object.assign(state.modified[modifiedIndex], modified)
|
else Object.assign(state.modified[modifiedIndex], modified)
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
case ARTICLE_UNCACHE:
|
||||||
|
{
|
||||||
|
let targetKey = action.data.key
|
||||||
|
let modifiedIndex = _.findIndex(state.modified, _article => targetKey === _article.key)
|
||||||
|
if (modifiedIndex >= 0) state.modified.splice(modifiedIndex, 1)
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
case ARTICLE_UNCACHE_ALL:
|
||||||
|
state.modified = []
|
||||||
|
return state
|
||||||
case ARTICLE_SAVE:
|
case ARTICLE_SAVE:
|
||||||
{
|
{
|
||||||
let targetKey = action.data.key
|
let targetKey = action.data.key
|
||||||
|
|||||||
Reference in New Issue
Block a user