feat(filters): ✨ store filters state in cookie
This commit is contained in:
parent
bdeb46a194
commit
6c406b5361
@ -1,3 +1,5 @@
|
|||||||
|
import { getCookie, setCookie } from '../utils/cookies.js'
|
||||||
|
|
||||||
export const settings = {
|
export const settings = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: {
|
state: {
|
||||||
@ -10,6 +12,17 @@ export const settings = {
|
|||||||
mutations: {
|
mutations: {
|
||||||
filters: (state, filters) => {
|
filters: (state, filters) => {
|
||||||
state.filters = { ...state.filters, ...filters }
|
state.filters = { ...state.filters, ...filters }
|
||||||
|
setCookie('repod.filters', JSON.stringify(state.filters), 365)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
fetch: (context) => {
|
||||||
|
try {
|
||||||
|
const filters = getCookie('repod.filters')
|
||||||
|
context.commit('filters', JSON.parse(filters))
|
||||||
|
} catch (e) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user