Throttle fetchOwnAccounts correctly
This commit is contained in:
parent
c14fc83ac1
commit
663d375dc5
2 changed files with 10 additions and 6 deletions
|
@ -1,6 +1,5 @@
|
|||
import api from '../api';
|
||||
import { importFetchedAccount } from './importer';
|
||||
import { throttle } from 'lodash';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
|
||||
export const SWITCH_ACCOUNT = 'SWITCH_ACCOUNT';
|
||||
|
@ -197,7 +196,7 @@ export function switchAccount(accountId) {
|
|||
}
|
||||
|
||||
export function fetchOwnAccounts() {
|
||||
return throttle((dispatch, getState) => {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
state.getIn(['auth', 'users']).forEach(user => {
|
||||
const account = state.getIn(['accounts', user.get('id')]);
|
||||
|
@ -205,7 +204,7 @@ export function fetchOwnAccounts() {
|
|||
dispatch(verifyCredentials(user.get('access_token')));
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
};
|
||||
}
|
||||
|
||||
export function register(params) {
|
||||
|
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||
import { connect } from 'react-redux';
|
||||
import { openModal } from '../../../actions/modal';
|
||||
import { fetchOwnAccounts } from 'soapbox/actions/auth';
|
||||
import { throttle } from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
|
||||
|
@ -69,12 +70,16 @@ class ProfileDropdown extends React.PureComponent {
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
fetchOwnAccounts = throttle(() => {
|
||||
this.props.dispatch(fetchOwnAccounts());
|
||||
}, 2000);
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchOwnAccounts();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.props.dispatch(fetchOwnAccounts());
|
||||
this.fetchOwnAccounts();
|
||||
}
|
||||
|
||||
renderAccount = account => {
|
||||
|
@ -104,7 +109,7 @@ class ProfileDropdown extends React.PureComponent {
|
|||
menu.push(null);
|
||||
}
|
||||
|
||||
menu.push({ text: intl.formatMessage(messages.add), action: this.handleAddAccount });
|
||||
menu.push({ text: intl.formatMessage(messages.add), to: '/auth/sign_in' });
|
||||
menu.push({ text: intl.formatMessage(messages.logout, { acct: account.get('acct') }), to: '/auth/sign_out', action: this.handleLogOut });
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue