From ad3362e3cdfdca19113e74c96c6288694183404c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 25 Mar 2021 20:32:40 -0500 Subject: [PATCH] auth: persist the state only if changed --- app/soapbox/reducers/auth.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/soapbox/reducers/auth.js b/app/soapbox/reducers/auth.js index 5509371bc..22e0d166b 100644 --- a/app/soapbox/reducers/auth.js +++ b/app/soapbox/reducers/auth.js @@ -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; };