pl-fe: fetch instance before calling verifyCredentials

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-04-15 20:55:38 +02:00
parent b248f15b1a
commit 39afc0d7de

View File

@ -176,13 +176,15 @@ interface VerifyCredentialsFailAction {
}
const verifyCredentials = (token: string, accountUrl?: string) =>
(dispatch: AppDispatch, getState: () => RootState) => {
async (dispatch: AppDispatch, getState: () => RootState) => {
const baseURL = parseBaseURL(accountUrl) || BuildConfig.BACKEND_URL;
dispatch<VerifyCredentialsRequestAction>({ type: VERIFY_CREDENTIALS_REQUEST, token });
const client = new PlApiClient(baseURL, token);
await client.instance.getInstance();
return client.settings.verifyCredentials().then((account) => {
dispatch(importEntities({ accounts: [account] }));
dispatch<VerifyCredentialsSuccessAction>({ type: VERIFY_CREDENTIALS_SUCCESS, token, account });