mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
Tidy up update class methods on PeerUI
This commit is contained in:
parent
00f1a20177
commit
5a56251ee3
1 changed files with 21 additions and 6 deletions
|
@ -459,7 +459,9 @@ class PeerUI {
|
||||||
this.$displayName.textContent = this._displayName();
|
this.$displayName.textContent = this._displayName();
|
||||||
this.$deviceName.textContent = this._deviceName();
|
this.$deviceName.textContent = this._deviceName();
|
||||||
|
|
||||||
this.updateTypesClassList();
|
this._updateRoomTypeClasses();
|
||||||
|
this._updateSameBrowserClass();
|
||||||
|
this._updateWsPeerClass();
|
||||||
|
|
||||||
this.setStatus("connect");
|
this.setStatus("connect");
|
||||||
|
|
||||||
|
@ -499,30 +501,40 @@ class PeerUI {
|
||||||
</label>`;
|
</label>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTypesClassList() {
|
_updateRoomTypeClasses() {
|
||||||
// Remove all classes
|
// Remove all classes
|
||||||
this.$el.classList.remove('type-ip', 'type-secret', 'type-public-id', 'type-same-browser', 'ws-peer');
|
this.$el.classList.remove('type-ip', 'type-secret', 'type-public-id');
|
||||||
|
|
||||||
// Add classes accordingly
|
// Add classes accordingly
|
||||||
Object.keys(this._roomIds).forEach(roomType => this.$el.classList.add(`type-${roomType}`));
|
Object.keys(this._roomIds).forEach(roomType => this.$el.classList.add(`type-${roomType}`));
|
||||||
|
|
||||||
if (BrowserTabsConnector.peerIsSameBrowser(this._peer.id)) {
|
|
||||||
this.$el.classList.add(`type-same-browser`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateSameBrowserClass() {
|
||||||
|
if (BrowserTabsConnector.peerIsSameBrowser(this._peer.id)) {
|
||||||
|
this.$el.classList.add('same-browser');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.$el.classList.remove('same-browser');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateWsPeerClass() {
|
||||||
if (!this._peer.rtcSupported || !window.isRtcSupported) {
|
if (!this._peer.rtcSupported || !window.isRtcSupported) {
|
||||||
this.$el.classList.add('ws-peer');
|
this.$el.classList.add('ws-peer');
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.$el.classList.remove('ws-peer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_addRoomId(roomType, roomId) {
|
_addRoomId(roomType, roomId) {
|
||||||
this._roomIds[roomType] = roomId;
|
this._roomIds[roomType] = roomId;
|
||||||
this.updateTypesClassList();
|
this._updateRoomTypeClasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeRoomId(roomType) {
|
_removeRoomId(roomType) {
|
||||||
delete this._roomIds[roomType];
|
delete this._roomIds[roomType];
|
||||||
this.updateTypesClassList();
|
this._updateRoomTypeClasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onShareModeChanged(active = false, descriptor = "") {
|
_onShareModeChanged(active = false, descriptor = "") {
|
||||||
|
@ -607,6 +619,9 @@ class PeerUI {
|
||||||
this._oldStatus = null;
|
this._oldStatus = null;
|
||||||
|
|
||||||
this._connectionHash = connectionHash;
|
this._connectionHash = connectionHash;
|
||||||
|
|
||||||
|
this._updateSameBrowserClass();
|
||||||
|
this._updateWsPeerClass();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._connected = false;
|
this._connected = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue