From 73a3ee296b8e692eb0c4910c52f5a3e76e36d5b0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 30 Mar 2021 00:45:23 -0500 Subject: [PATCH] Rename action.reload -> action.background --- app/soapbox/actions/auth.js | 4 ++-- app/soapbox/features/ui/components/profile_dropdown.js | 2 +- app/soapbox/reducers/auth.js | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/soapbox/actions/auth.js b/app/soapbox/actions/auth.js index 8f6345508..bc714be39 100644 --- a/app/soapbox/actions/auth.js +++ b/app/soapbox/actions/auth.js @@ -190,8 +190,8 @@ export function logOut() { }; } -export function switchAccount(accountId, reload = true) { - return { type: SWITCH_ACCOUNT, accountId, reload }; +export function switchAccount(accountId, background = false) { + return { type: SWITCH_ACCOUNT, accountId, background }; } export function fetchOwnAccounts() { diff --git a/app/soapbox/features/ui/components/profile_dropdown.js b/app/soapbox/features/ui/components/profile_dropdown.js index b63502694..d73005da3 100644 --- a/app/soapbox/features/ui/components/profile_dropdown.js +++ b/app/soapbox/features/ui/components/profile_dropdown.js @@ -66,7 +66,7 @@ class ProfileDropdown extends React.PureComponent { handleMiddleClick = account => { return e => { - this.props.dispatch(switchAccount(account.get('id'), false)); + this.props.dispatch(switchAccount(account.get('id'), true)); window.open('/', '_blank', 'noopener,noreferrer'); e.preventDefault(); }; diff --git a/app/soapbox/reducers/auth.js b/app/soapbox/reducers/auth.js index 4c3af84c7..5be27ac1a 100644 --- a/app/soapbox/reducers/auth.js +++ b/app/soapbox/reducers/auth.js @@ -154,7 +154,6 @@ const userSwitched = (oldState, state) => { }; const maybeReload = (oldState, state, action) => { - if (action.reload === false) return; if (userSwitched(oldState, state)) { reload(state); } @@ -167,7 +166,9 @@ export default function auth(oldState = initialState, action) { // Persist the state in localStorage persistAuth(state); - if (action.reload === false) { + // When middle-clicking a profile, we want to save the + // user in localStorage, but not update the reducer + if (action.background === true) { return oldState; }