[Glitch] Fix instance api account merging
Port 0688e64a0b2839ee3bcfcaa16aedf5f6cd0d33ab to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
0e154b859f
commit
fcd00902d1
@ -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