[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:
Echo 2026-01-30 10:30:22 +01:00 committed by Claire
parent 0e154b859f
commit fcd00902d1

View File

@ -27,7 +27,15 @@ export const fetchServer = () => (dispatch, getState) => {
api()
.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));
}).catch(err => dispatch(fetchServerFail(err)));
};