auth: persist the state only if changed

This commit is contained in:
Alex Gleason 2021-03-25 20:32:40 -05:00
parent fa4d36b7a7
commit ad3362e3cd
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 5 additions and 3 deletions

View File

@ -162,10 +162,12 @@ export default function auth(oldState = initialState, action) {
const state = reducer(oldState, action);
// Persist the state in localStorage
if (!state.equals(oldState)) {
localStorage.setItem('soapbox:auth', JSON.stringify(state.toJS()));
// Reload the page under some conditions
maybeReload(oldState, state, action);
}
return state;
};