Revert "Revert "Sign out when session is terminated from another application""
This reverts commit 45deb91ada282519de34599d4c88487d8df9001f.
This commit is contained in:
parent
588a340d60
commit
f26e2d41fb
@ -97,6 +97,8 @@ export async function destroy() {
|
|||||||
function handleGramJsUpdate(update: any) {
|
function handleGramJsUpdate(update: any) {
|
||||||
if (update instanceof connection.UpdateConnectionState) {
|
if (update instanceof connection.UpdateConnectionState) {
|
||||||
isConnected = update.state === connection.UpdateConnectionState.connected;
|
isConnected = update.state === connection.UpdateConnectionState.connected;
|
||||||
|
} else if (update instanceof GramJs.UpdatesTooLong) {
|
||||||
|
void handleTerminatedSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,3 +233,18 @@ function injectUpdateEntities(result: GramJs.Updates | GramJs.UpdatesCombined) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleTerminatedSession() {
|
||||||
|
try {
|
||||||
|
await invokeRequest(new GramJs.users.GetFullUser({
|
||||||
|
id: new GramJs.InputUserSelf(),
|
||||||
|
}), undefined, true);
|
||||||
|
} catch (err) {
|
||||||
|
if (err.message === 'AUTH_KEY_UNREGISTERED') {
|
||||||
|
onUpdate({
|
||||||
|
'@type': 'updateConnectionState',
|
||||||
|
connectionState: 'connectionStateBroken',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user