mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
fix: manage errors extensions
This commit is contained in:
1 parent
afd99a1dfe
commit
207b9ae36c
1 file changed
+21
-12
@@ -9,13 +9,18 @@ import * as App from '../../stores/app';
|
|||||||
import { CURRENT_POLICIES_AGREEMENT_INDEX } from '../../stores/app/constants';
|
import { CURRENT_POLICIES_AGREEMENT_INDEX } from '../../stores/app/constants';
|
||||||
import { PatreonAuthResponse } from '../auth/[provider]/page';
|
import { PatreonAuthResponse } from '../auth/[provider]/page';
|
||||||
|
|
||||||
interface Extension {
|
type Extension =
|
||||||
data: {
|
| {
|
||||||
access_token: string;
|
status: 'ok';
|
||||||
account_id: number;
|
data: {
|
||||||
expires_at: number;
|
access_token: string;
|
||||||
};
|
account_id: number;
|
||||||
}
|
expires_at: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
status: 'error';
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wargaming: 14 (refresh: 7)
|
* Wargaming: 14 (refresh: 7)
|
||||||
@@ -80,11 +85,15 @@ export function Checks() {
|
|||||||
.then((response) => response.json() as Promise<Extension>)
|
.then((response) => response.json() as Promise<Extension>)
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
mutateApp((draft) => {
|
mutateApp((draft) => {
|
||||||
draft.logins.wargaming = {
|
if (json.status === 'error') {
|
||||||
id: wargaming.id,
|
draft.logins.wargaming = undefined;
|
||||||
token: json.data.access_token,
|
} else {
|
||||||
expires: json.data.expires_at * 1000,
|
draft.logins.wargaming = {
|
||||||
};
|
id: wargaming.id,
|
||||||
|
token: json.data.access_token,
|
||||||
|
expires: json.data.expires_at * 1000,
|
||||||
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user