feat(filters): store filters state in cookie
All checks were successful
repod / xml (push) Successful in 21s
repod / php (push) Successful in 37s
repod / nodejs (push) Successful in 2m29s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2024-03-05 10:50:50 +01:00
parent bdeb46a194
commit 6c406b5361

View File

@ -1,3 +1,5 @@
import { getCookie, setCookie } from '../utils/cookies.js'
export const settings = {
namespaced: true,
state: {
@ -10,6 +12,17 @@ export const settings = {
mutations: {
filters: (state, 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
}
},
},
}