Skip to content

Commit

Permalink
Make state filtering more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Mar 15, 2024
1 parent 7b6fc7a commit 8c44218
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ api.namespaced = true;

export default new Vuex.Store({
state() {
return { title: null, filterSummary: null, filterDescription: null, debug: debug, lastError: null};
return { title: null, filterSummary: null, filterDescription: null, debug: debug, lastError: null };
},
mutations: {
setDebug(state, newVal) {
Expand All @@ -34,13 +34,14 @@ export default new Vuex.Store({
plugins: [
CreatePersistedState({
reducer: (persistedState) => {
const stateFilter = JSON.parse(JSON.stringify(persistedState));
// Remove stuff we do not want to persist for any reason
delete stateFilter.api["pending"]; // Pending is only valid at runtime
// copy objects to avoid modifying the original state
const stateFilter = { ...persistedState, api: { ...persistedState.api } };
// pending requests and errors is only valid at runtime
delete stateFilter.api["pending"];
delete stateFilter.api["error"];
delete stateFilter["title"];
delete stateFilter["filterSummary"]
delete stateFilter["filterDescription"]
delete stateFilter["filterSummary"];
delete stateFilter["filterDescription"];
delete stateFilter["lastError"];
return stateFilter;
}
Expand Down

0 comments on commit 8c44218

Please sign in to comment.