GramJS: Fix showing file connection disconnect in UI (#4483)
This commit is contained in:
parent
11cbab7d39
commit
917dc1171b
@ -233,13 +233,13 @@ class MTProtoSender {
|
|||||||
this.logWithIndex.warn('Connecting...');
|
this.logWithIndex.warn('Connecting...');
|
||||||
await this._connect(this.getConnection());
|
await this._connect(this.getConnection());
|
||||||
this.logWithIndex.warn('Connected!');
|
this.logWithIndex.warn('Connected!');
|
||||||
if (this._updateCallback) {
|
if (!this._isExported) {
|
||||||
this._updateCallback(new UpdateConnectionState(UpdateConnectionState.connected));
|
this._updateCallback?.(new UpdateConnectionState(UpdateConnectionState.connected));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (this._updateCallback && attempt === 0) {
|
if (!this._isExported && attempt === 0) {
|
||||||
this._updateCallback(new UpdateConnectionState(UpdateConnectionState.disconnected));
|
this._updateCallback?.(new UpdateConnectionState(UpdateConnectionState.disconnected));
|
||||||
}
|
}
|
||||||
this._log.error(`${this._isFallback ? 'HTTP' : 'WebSocket'} connection failed attempt: ${attempt + 1}`);
|
this._log.error(`${this._isFallback ? 'HTTP' : 'WebSocket'} connection failed attempt: ${attempt + 1}`);
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
@ -382,8 +382,8 @@ class MTProtoSender {
|
|||||||
|
|
||||||
this._state.timeOffset = res.timeOffset;
|
this._state.timeOffset = res.timeOffset;
|
||||||
|
|
||||||
if (this._updateCallback) {
|
if (!this._isExported) {
|
||||||
this._updateCallback(new UpdateServerTimeOffset(this._state.timeOffset));
|
this._updateCallback?.(new UpdateServerTimeOffset(this._state.timeOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -425,8 +425,8 @@ class MTProtoSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _disconnect(connection) {
|
async _disconnect(connection) {
|
||||||
if (this._updateCallback) {
|
if (!this._isExported) {
|
||||||
this._updateCallback(new UpdateConnectionState(UpdateConnectionState.disconnected));
|
this._updateCallback?.(new UpdateConnectionState(UpdateConnectionState.disconnected));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connection === undefined) {
|
if (connection === undefined) {
|
||||||
@ -692,8 +692,8 @@ class MTProtoSender {
|
|||||||
|
|
||||||
this._log.warn(`Broken authorization key for dc ${this._dcId}, resetting...`);
|
this._log.warn(`Broken authorization key for dc ${this._dcId}, resetting...`);
|
||||||
|
|
||||||
if (this._isMainSender && this._updateCallback) {
|
if (this._isMainSender && !this._isExported) {
|
||||||
this._updateCallback(new UpdateConnectionState(UpdateConnectionState.broken));
|
this._updateCallback?.(new UpdateConnectionState(UpdateConnectionState.broken));
|
||||||
} else if (!this._isMainSender && this._onConnectionBreak) {
|
} else if (!this._isMainSender && this._onConnectionBreak) {
|
||||||
this._onConnectionBreak(this._dcId);
|
this._onConnectionBreak(this._dcId);
|
||||||
}
|
}
|
||||||
@ -858,8 +858,8 @@ class MTProtoSender {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._log.debug(`Handling update ${message.obj.className}`);
|
this._log.debug(`Handling update ${message.obj.className}`);
|
||||||
if (this._updateCallback) {
|
if (!this._isExported) {
|
||||||
this._updateCallback(message.obj);
|
this._updateCallback?.(message.obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,8 +875,8 @@ class MTProtoSender {
|
|||||||
const pong = message.obj;
|
const pong = message.obj;
|
||||||
|
|
||||||
const newTimeOffset = this._state.updateTimeOffset(message.msgId);
|
const newTimeOffset = this._state.updateTimeOffset(message.msgId);
|
||||||
if (this._updateCallback) {
|
if (!this._isExported) {
|
||||||
this._updateCallback(new UpdateServerTimeOffset(newTimeOffset));
|
this._updateCallback?.(new UpdateServerTimeOffset(newTimeOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._log.debug(`Handling pong for message ${pong.msgId}`);
|
this._log.debug(`Handling pong for message ${pong.msgId}`);
|
||||||
@ -924,8 +924,8 @@ class MTProtoSender {
|
|||||||
// Use the current msg_id to determine the right time offset.
|
// Use the current msg_id to determine the right time offset.
|
||||||
const newTimeOffset = this._state.updateTimeOffset(message.msgId);
|
const newTimeOffset = this._state.updateTimeOffset(message.msgId);
|
||||||
|
|
||||||
if (this._updateCallback) {
|
if (!this._isExported) {
|
||||||
this._updateCallback(new UpdateServerTimeOffset(newTimeOffset));
|
this._updateCallback?.(new UpdateServerTimeOffset(newTimeOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._log.info(`System clock is wrong, set time offset to ${newTimeOffset}s`);
|
this._log.info(`System clock is wrong, set time offset to ${newTimeOffset}s`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user