Fix instance api account merging (#37666)
This commit is contained in:
parent
0997ae0627
commit
0688e64a0b
@ -27,7 +27,15 @@ export const fetchServer = () => (dispatch, getState) => {
|
|||||||
|
|
||||||
api()
|
api()
|
||||||
.get('/api/v2/instance').then(({ data }) => {
|
.get('/api/v2/instance').then(({ data }) => {
|
||||||
if (data.contact.account) dispatch(importFetchedAccount(data.contact.account));
|
// Only import the account if it doesn't already exist,
|
||||||
|
// because the API is cached even for logged in users.
|
||||||
|
const account = data.contact.account;
|
||||||
|
if (account) {
|
||||||
|
const existingAccount = getState().getIn(['accounts', account.id]);
|
||||||
|
if (!existingAccount) {
|
||||||
|
dispatch(importFetchedAccount(account));
|
||||||
|
}
|
||||||
|
}
|
||||||
dispatch(fetchServerSuccess(data));
|
dispatch(fetchServerSuccess(data));
|
||||||
}).catch(err => dispatch(fetchServerFail(err)));
|
}).catch(err => dispatch(fetchServerFail(err)));
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user