From bef745901978a793d5c63bab6a1cf9a1dea3d72c Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Tue, 10 Jan 2023 16:10:35 +0100 Subject: [PATCH] do not hide ReceiveDialogs on disconnect --- public/scripts/network.js | 4 +--- public/scripts/ui.js | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/public/scripts/network.js b/public/scripts/network.js index e584227..1d7df5a 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -8,9 +8,7 @@ class ServerConnection { Events.on('beforeunload', _ => this._disconnect()); Events.on('pagehide', _ => this._disconnect()); document.addEventListener('visibilitychange', _ => this._onVisibilityChange()); - if (navigator.connection) { - navigator.connection.addEventListener('change', _ => this._disconnect()); - } + if (navigator.connection) navigator.connection.addEventListener('change', _ => this._disconnect()); Events.on('reconnect', _ => this._reconnect()); Events.on('room-secrets', e => this._sendRoomSecrets(e.detail)); Events.on('room-secret-deleted', e => this.send({ type: 'room-secret-deleted', roomSecret: e.detail})); diff --git a/public/scripts/ui.js b/public/scripts/ui.js index 17b493a..a2d63e2 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -391,11 +391,11 @@ class PeerUI { class Dialog { - constructor(id) { + constructor(id, hideOnDisconnect = true) { this.$el = $(id); this.$el.querySelectorAll('[close]').forEach(el => el.addEventListener('click', _ => this.hide())) this.$autoFocus = this.$el.querySelector('[autofocus]'); - Events.on('ws-disconnected', _ => this.hide()); + if (hideOnDisconnect) Events.on('ws-disconnected', _ => this.hide()); } show() { @@ -415,7 +415,7 @@ class Dialog { class ReceiveDialog extends Dialog { constructor() { - super('receiveDialog'); + super('receiveDialog', false); Events.on('file-received', e => { this._nextFile(e.detail); window.blop.play(); @@ -802,7 +802,7 @@ class SendTextDialog extends Dialog { class ReceiveTextDialog extends Dialog { constructor() { - super('receiveTextDialog'); + super('receiveTextDialog', false); Events.on('text-received', e => this._onText(e.detail)) this.$text = this.$el.querySelector('#text'); const copy = this.$el.querySelector('#copy');