Skip to content

Commit 903a08c

Browse files
committed
reset categories
1 parent d4c1ef0 commit 903a08c

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/vuex/modules/category/actions.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import wordpressService from '../../../app.service'
2+
import defaultState from './defaultState'
23

34
const getCategoryPromises = ({commit, state}, responseCategories, page) => {
45
var postPromises = []
@@ -22,11 +23,9 @@ const getCategory = ({commit, state, dispatch}, params) => {
2223
params.page = 1
2324
}
2425

25-
// TODO: Reset categories, single while loading new ones
26-
// if (typeof window !== 'undefined') {
27-
// state.categories = []
28-
// state.single = {}
29-
// }
26+
if (typeof window !== 'undefined') {
27+
Object.assign(state, defaultState)
28+
}
3029

3130
return new Promise((resolve, reject) => {
3231
wordpressService.getCategory(null, params.categorySlug, params.parentId).then((responseCategories) => {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const defaultState = {
2+
categories: [],
3+
single: {},
4+
page: 1
5+
}
6+
7+
export default defaultState

src/vuex/modules/category/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import * as actions from './actions'
22
import * as getters from './getters'
33
import * as mutations from './mutations'
4-
5-
const defaultState = {
6-
categories: [],
7-
single: {},
8-
page: 1
9-
}
4+
import defaultState from './defaultState'
105

116
const inBrowser = typeof window !== 'undefined'
127
// if in browser, use pre-fetched state injected by SSR

0 commit comments

Comments
 (0)