Stop usage of public class fields in order to support Safari 13.1

This commit is contained in:
schlagmichdoch 2025-02-13 10:24:27 +01:00
parent 44c0f3dbaa
commit 940da7948c

View file

@ -18,11 +18,12 @@ class PeersUI {
this.peers = {}; this.peers = {};
this.shareMode = {}; this.shareMode = {
this.shareMode.active = false; active: false,
this.shareMode.descriptor = ""; descriptor: "",
this.shareMode.files = []; files: [],
this.shareMode.text = ""; text: ""
}
Events.on('peer-joined', e => this._onPeerJoined(e.detail)); Events.on('peer-joined', e => this._onPeerJoined(e.detail));
Events.on('peer-added', _ => this._evaluateOverflowingPeers()); Events.on('peer-added', _ => this._evaluateOverflowingPeers());
@ -394,12 +395,6 @@ class PeersUI {
class PeerUI { class PeerUI {
static _badgeClassNames = ["badge-room-ip", "badge-room-secret", "badge-room-public-id"];
static _shareMode = {
active: false,
descriptor: ""
};
constructor(peer, connectionHash, shareMode) { constructor(peer, connectionHash, shareMode) {
this.$xInstructions = $$('x-instructions'); this.$xInstructions = $$('x-instructions');
this.$xPeers = $$('x-peers'); this.$xPeers = $$('x-peers');
@ -409,7 +404,7 @@ class PeerUI {
`${connectionHash.substring(0, 4)} ${connectionHash.substring(4, 8)} ${connectionHash.substring(8, 12)} ${connectionHash.substring(12, 16)}`; `${connectionHash.substring(0, 4)} ${connectionHash.substring(4, 8)} ${connectionHash.substring(8, 12)} ${connectionHash.substring(12, 16)}`;
// This is needed if the ShareMode is started BEFORE the PeerUI is drawn. // This is needed if the ShareMode is started BEFORE the PeerUI is drawn.
PeerUI._shareMode = shareMode; this._shareMode = shareMode;
this._initDom(); this._initDom();
@ -421,8 +416,8 @@ class PeerUI {
} }
html() { html() {
let title= PeerUI._shareMode.active let title= this._shareMode.active
? Localization.getTranslation("peer-ui.click-to-send-share-mode", null, {descriptor: PeerUI._shareMode.descriptor}) ? Localization.getTranslation("peer-ui.click-to-send-share-mode", null, {descriptor: this._shareMode.descriptor})
: Localization.getTranslation("peer-ui.click-to-send"); : Localization.getTranslation("peer-ui.click-to-send");
this.$el.innerHTML = ` this.$el.innerHTML = `
@ -485,8 +480,8 @@ class PeerUI {
_onShareModeChanged(active = false, descriptor = "") { _onShareModeChanged(active = false, descriptor = "") {
// This is needed if the ShareMode is started AFTER the PeerUI is drawn. // This is needed if the ShareMode is started AFTER the PeerUI is drawn.
PeerUI._shareMode.active = active; this._shareMode.active = active;
PeerUI._shareMode.descriptor = descriptor; this._shareMode.descriptor = descriptor;
this._evaluateShareMode(); this._evaluateShareMode();
this._bindListeners(); this._bindListeners();
@ -494,12 +489,12 @@ class PeerUI {
_evaluateShareMode() { _evaluateShareMode() {
let title; let title;
if (!PeerUI._shareMode.active) { if (!this._shareMode.active) {
title = Localization.getTranslation("peer-ui.click-to-send"); title = Localization.getTranslation("peer-ui.click-to-send");
this.$input.removeAttribute('disabled'); this.$input.removeAttribute('disabled');
} }
else { else {
title = Localization.getTranslation("peer-ui.click-to-send-share-mode", null, {descriptor: PeerUI._shareMode.descriptor}); title = Localization.getTranslation("peer-ui.click-to-send-share-mode", null, {descriptor: this._shareMode.descriptor});
this.$input.setAttribute('disabled', true); this.$input.setAttribute('disabled', true);
} }
this.$label.setAttribute('title', title); this.$label.setAttribute('title', title);
@ -520,7 +515,7 @@ class PeerUI {
} }
_bindListeners() { _bindListeners() {
if(!PeerUI._shareMode.active) { if(!this._shareMode.active) {
// Remove Events Share mode // Remove Events Share mode
this.$el.removeEventListener('pointerdown', this._callbackPointerDown); this.$el.removeEventListener('pointerdown', this._callbackPointerDown);
@ -636,7 +631,7 @@ class PeerUI {
} }
_onDrop(e) { _onDrop(e) {
if (PeerUI._shareMode.active || Dialog.anyDialogShown()) return; if (this._shareMode.active || Dialog.anyDialogShown()) return;
e.preventDefault(); e.preventDefault();
@ -1974,7 +1969,7 @@ class SendTextDialog extends Dialog {
_onRecipient(peerId, deviceName) { _onRecipient(peerId, deviceName) {
this.correspondingPeerId = peerId; this.correspondingPeerId = peerId;
this.$peerDisplayName.innerText = deviceName; this.$peerDisplayName.innerText = deviceName;
this.$peerDisplayName.classList.remove(...PeerUI._badgeClassNames); this.$peerDisplayName.classList.remove("badge-room-ip", "badge-room-secret", "badge-room-public-id");
this.$peerDisplayName.classList.add($(peerId).ui._badgeClassName()); this.$peerDisplayName.classList.add($(peerId).ui._badgeClassName());
this.show(); this.show();
@ -2056,7 +2051,7 @@ class ReceiveTextDialog extends Dialog {
_showReceiveTextDialog(text, peerId) { _showReceiveTextDialog(text, peerId) {
this.$displayName.innerText = $(peerId).ui._displayName(); this.$displayName.innerText = $(peerId).ui._displayName();
this.$displayName.classList.remove(...PeerUI._badgeClassNames); this.$displayName.classList.remove("badge-room-ip", "badge-room-secret", "badge-room-public-id");
this.$displayName.classList.add($(peerId).ui._badgeClassName()); this.$displayName.classList.add($(peerId).ui._badgeClassName());
this.$text.innerText = text; this.$text.innerText = text;