Merge branch 'verify_credentials-loop' into 'develop'

Stop verify_credentials infinite loop, partial fix for #613

Closes #613

See merge request soapbox-pub/soapbox-fe!473
This commit is contained in:
Alex Gleason 2021-04-10 23:22:37 +00:00
commit dd417c19da
3 changed files with 18 additions and 7 deletions

View file

@ -17,7 +17,7 @@ import { makeGetAccount } from '../selectors';
import { logOut, switchAccount } from 'soapbox/actions/auth'; import { logOut, switchAccount } from 'soapbox/actions/auth';
import ThemeToggle from '../features/ui/components/theme_toggle_container'; import ThemeToggle from '../features/ui/components/theme_toggle_container';
import { fetchOwnAccounts } from 'soapbox/actions/auth'; import { fetchOwnAccounts } from 'soapbox/actions/auth';
import { List as ImmutableList } from 'immutable'; import { List as ImmutableList, is as ImmutableIs } from 'immutable';
const messages = defineMessages({ const messages = defineMessages({
followers: { id: 'account.followers', defaultMessage: 'Followers' }, followers: { id: 'account.followers', defaultMessage: 'Followers' },
@ -63,7 +63,6 @@ const mapStateToProps = state => {
donateUrl: state.getIn(['patron', 'instance', 'url']), donateUrl: state.getIn(['patron', 'instance', 'url']),
isStaff: isStaff(state.getIn(['accounts', me])), isStaff: isStaff(state.getIn(['accounts', me])),
otherAccounts, otherAccounts,
}; };
}; };
@ -90,6 +89,7 @@ class SidebarMenu extends ImmutablePureComponent {
static propTypes = { static propTypes = {
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
account: ImmutablePropTypes.map, account: ImmutablePropTypes.map,
otherAccounts: ImmutablePropTypes.list,
sidebarOpen: PropTypes.bool, sidebarOpen: PropTypes.bool,
onClose: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired,
isStaff: PropTypes.bool.isRequired, isStaff: PropTypes.bool.isRequired,
@ -128,9 +128,14 @@ class SidebarMenu extends ImmutablePureComponent {
this.fetchOwnAccounts(); this.fetchOwnAccounts();
} }
componentDidUpdate() { componentDidUpdate(prevProps) {
const accountChanged = !ImmutableIs(prevProps.account, this.props.account);
const otherAccountsChanged = !ImmutableIs(prevProps.otherAccounts, this.props.otherAccounts);
if (accountChanged || otherAccountsChanged) {
this.fetchOwnAccounts(); this.fetchOwnAccounts();
} }
}
renderAccount = account => { renderAccount = account => {
return ( return (

View file

@ -8,7 +8,7 @@ import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
import { isStaff } from 'soapbox/utils/accounts'; import { isStaff } from 'soapbox/utils/accounts';
import { defineMessages, injectIntl } from 'react-intl'; import { defineMessages, injectIntl } from 'react-intl';
import { logOut, switchAccount } from 'soapbox/actions/auth'; import { logOut, switchAccount } from 'soapbox/actions/auth';
import { List as ImmutableList } from 'immutable'; import { List as ImmutableList, is as ImmutableIs } from 'immutable';
import Avatar from 'soapbox/components/avatar'; import Avatar from 'soapbox/components/avatar';
import DisplayName from 'soapbox/components/display_name'; import DisplayName from 'soapbox/components/display_name';
@ -80,9 +80,14 @@ class ProfileDropdown extends React.PureComponent {
this.fetchOwnAccounts(); this.fetchOwnAccounts();
} }
componentDidUpdate() { componentDidUpdate(prevProps) {
const accountChanged = !ImmutableIs(prevProps.account, this.props.account);
const otherAccountsChanged = !ImmutableIs(prevProps.otherAccounts, this.props.otherAccounts);
if (accountChanged || otherAccountsChanged) {
this.fetchOwnAccounts(); this.fetchOwnAccounts();
} }
}
renderAccount = account => { renderAccount = account => {
return ( return (

View file

@ -24,6 +24,7 @@ const initialState = ImmutableMap();
const normalizePleroma = account => { const normalizePleroma = account => {
if (!account.pleroma) return account; if (!account.pleroma) return account;
account.pleroma = normalizePleromaUserFields(account.pleroma); account.pleroma = normalizePleromaUserFields(account.pleroma);
delete account.pleroma.chat_token;
return account; return account;
}; };