auth: persist the state only if changed

bundle-emoji
Alex Gleason 2021-03-25 20:32:40 -05:00
rodzic fa4d36b7a7
commit ad3362e3cd
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

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