mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 20:11:32 +02:00
[ide-react] Avoid showing disconnected message if leaving page (#16263)
GitOrigin-RevId: bda7ed207a66b0f051d284cd9b31a20b2c93edca
This commit is contained in:
@@ -41,6 +41,7 @@ export class ConnectionManager extends Emitter<Events> {
|
||||
private readonly idleDisconnectInterval: number
|
||||
private reconnectCountdownInterval = 0
|
||||
readonly socket: Socket
|
||||
private userIsLeavingPage = false
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
@@ -51,6 +52,9 @@ export class ConnectionManager extends Emitter<Events> {
|
||||
}, ONE_HOUR_IN_MS)
|
||||
|
||||
window.addEventListener('online', () => this.onOnline())
|
||||
window.addEventListener('beforeunload', () => {
|
||||
this.userIsLeavingPage = true
|
||||
})
|
||||
|
||||
const socket = SocketIoShim.connect('', {
|
||||
'auto connect': false,
|
||||
@@ -85,6 +89,7 @@ export class ConnectionManager extends Emitter<Events> {
|
||||
// Called when document is clicked or the editor cursor changes
|
||||
registerUserActivity() {
|
||||
this.lastUserActivity = performance.now()
|
||||
this.userIsLeavingPage = false
|
||||
this.ensureIsConnected()
|
||||
}
|
||||
|
||||
@@ -273,6 +278,7 @@ export class ConnectionManager extends Emitter<Events> {
|
||||
}
|
||||
|
||||
private startAutoReconnectCountdown(backoff: number) {
|
||||
if (this.userIsLeavingPage) return
|
||||
if (!this.canReconnect()) return
|
||||
let countdown
|
||||
if (this.isUserInactiveSince(TWO_MINUTES_IN_MS)) {
|
||||
|
||||
Reference in New Issue
Block a user