mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-22 05:11:55 +01:00
GramJs: Temporary workaround for logouts on launch, add WS logging (#1290)
This commit is contained in:
parent
4e4299bf39
commit
9794b62ec8
@ -79,12 +79,15 @@ export async function init(_onUpdate: OnApiUpdate, initialArgs: ApiInitialArgs)
|
||||
initialMethod: platform === 'iOS' || platform === 'Android' ? 'phoneNumber' : 'qrCode',
|
||||
});
|
||||
} catch (err) {
|
||||
onUpdate({
|
||||
'@type': 'updateConnectionState',
|
||||
connectionState: 'connectionStateBroken',
|
||||
});
|
||||
// TODO Investigate which request causes this exception
|
||||
if (err.message !== 'Disconnect') {
|
||||
onUpdate({
|
||||
'@type': 'updateConnectionState',
|
||||
connectionState: 'connectionStateBroken',
|
||||
});
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
|
@ -614,6 +614,7 @@ class TelegramClient {
|
||||
* @param request
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
async invoke(request) {
|
||||
if (request.classType !== 'request') {
|
||||
throw new Error('You can only invoke MTProtoRequests');
|
||||
|
@ -56,6 +56,7 @@ export async function checkAuthorization(client: TelegramClient) {
|
||||
await client.invoke(new Api.updates.GetState());
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (e.message === 'Disconnect') throw e;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,9 @@ class PromisedWebSockets {
|
||||
this.client.onerror = (error) => {
|
||||
reject(error);
|
||||
};
|
||||
this.client.onclose = () => {
|
||||
this.client.onclose = (event) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`Socket closed with code: ${event.code}`);
|
||||
this.resolveRead(false);
|
||||
this.closed = true;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user