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

View file

@ -8,7 +8,7 @@ import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
import { isStaff } from 'soapbox/utils/accounts';
import { defineMessages, injectIntl } from 'react-intl';
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 DisplayName from 'soapbox/components/display_name';
@ -80,8 +80,13 @@ class ProfileDropdown extends React.PureComponent {
this.fetchOwnAccounts();
}
componentDidUpdate() {
this.fetchOwnAccounts();
componentDidUpdate(prevProps) {
const accountChanged = !ImmutableIs(prevProps.account, this.props.account);
const otherAccountsChanged = !ImmutableIs(prevProps.otherAccounts, this.props.otherAccounts);
if (accountChanged || otherAccountsChanged) {
this.fetchOwnAccounts();
}
}
renderAccount = account => {

View file

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