From 36e152dc7c1d4a112c0f11c89336291963055b2a Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Mon, 6 Mar 2023 11:59:56 +0100 Subject: [PATCH] add { once: true } to deactivate-paste-mode event listener --- public/scripts/network.js | 8 ++++---- public/scripts/ui.js | 2 +- public_included_ws_fallback/scripts/network.js | 8 ++++---- public_included_ws_fallback/scripts/ui.js | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/public/scripts/network.js b/public/scripts/network.js index 55fdc89..01eb27d 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -893,11 +893,11 @@ class Events { window.dispatchEvent(new CustomEvent(type, { detail: detail })); } - static on(type, callback) { - return window.addEventListener(type, callback, false); + static on(type, callback, options = false) { + return window.addEventListener(type, callback, options); } - static off(type, callback) { - return window.removeEventListener(type, callback, false); + static off(type, callback, options = false) { + return window.removeEventListener(type, callback, options); } } diff --git a/public/scripts/ui.js b/public/scripts/ui.js index 62c1f83..340b22b 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -241,7 +241,7 @@ class PeersUI { const _callback = (e) => this._sendClipboardData(e, files, text); Events.on('paste-pointerdown', _callback); - Events.on('deactivate-paste-mode', _ => this._deactivatePasteMode(_callback)); + Events.on('deactivate-paste-mode', _ => this._deactivatePasteMode(_callback), { once: true }); this.$cancelPasteModeBtn.removeAttribute('hidden'); diff --git a/public_included_ws_fallback/scripts/network.js b/public_included_ws_fallback/scripts/network.js index 4c5b255..b805654 100644 --- a/public_included_ws_fallback/scripts/network.js +++ b/public_included_ws_fallback/scripts/network.js @@ -974,11 +974,11 @@ class Events { window.dispatchEvent(new CustomEvent(type, { detail: detail })); } - static on(type, callback) { - return window.addEventListener(type, callback, false); + static on(type, callback, options = false) { + return window.addEventListener(type, callback, options); } - static off(type, callback) { - return window.removeEventListener(type, callback, false); + static off(type, callback, options = false) { + return window.removeEventListener(type, callback, options); } } diff --git a/public_included_ws_fallback/scripts/ui.js b/public_included_ws_fallback/scripts/ui.js index b1f666b..0227167 100644 --- a/public_included_ws_fallback/scripts/ui.js +++ b/public_included_ws_fallback/scripts/ui.js @@ -241,7 +241,7 @@ class PeersUI { const _callback = (e) => this._sendClipboardData(e, files, text); Events.on('paste-pointerdown', _callback); - Events.on('deactivate-paste-mode', _ => this._deactivatePasteMode(_callback)); + Events.on('deactivate-paste-mode', _ => this._deactivatePasteMode(_callback), { once: true }); this.$cancelPasteModeBtn.removeAttribute('hidden');