Only save partial state
This commit is contained in:
parent
2b556222ed
commit
8b4ebadec2
@ -19,14 +19,14 @@ const store = createStore({
|
||||
let store = localStorage.getItem("store");
|
||||
if(store){
|
||||
this.replaceState(
|
||||
Object.assign(state, store)
|
||||
Object.assign(state, JSON.parse(store))
|
||||
);
|
||||
}
|
||||
},
|
||||
getDashboard (state) {
|
||||
fetch("/api/v1/dashboard", {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + state.Token
|
||||
'Authorization': 'Bearer ' + state.Session.Token
|
||||
}
|
||||
})
|
||||
.then(x => x.json())
|
||||
@ -37,13 +37,18 @@ const store = createStore({
|
||||
document.title = "Budgeteer - " + title;
|
||||
},
|
||||
setToken(state, token) {
|
||||
state.Token = token;
|
||||
state.Session.Token = token;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
store.subscribe((mutation, state) => {
|
||||
localStorage.setItem("store", JSON.stringify(state));
|
||||
let persistedState = {
|
||||
Session: state.Session,
|
||||
Budgets: state.Budgets,
|
||||
CurrentBudget: state.CurrentBudget
|
||||
}
|
||||
localStorage.setItem("store", JSON.stringify(persistedState));
|
||||
})
|
||||
|
||||
const app = createApp(App)
|
||||
|
Loading…
x
Reference in New Issue
Block a user