Skip to content

Commit

Permalink
Replace shorter tenary expression with if-statements
Browse files Browse the repository at this point in the history
This is required to adhere to @typescript-eslint/no-unused-expressions
  • Loading branch information
Philzen committed Dec 29, 2024
1 parent f75f4c4 commit a40187a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
this.options = new Proxy(this.options, {
set: (target: InternalRoomOptions, key: keyof InternalRoomOptions, value) => {
if (key == 'disconnectOnPageLeave' && value !== target[key]) {
value === true ? this.registerUnloadEvents() : this.unregisterUnloadEvents()
if (value === true) {
this.registerUnloadEvents()
} else {
this.unregisterUnloadEvents()
}
}

(target[key] as any) = value
Expand Down Expand Up @@ -777,7 +781,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
}

if (isWeb()) {
this.options.disconnectOnPageLeave && this.registerUnloadEvents()
if (this.options.disconnectOnPageLeave) {
this.registerUnloadEvents()
}
document.addEventListener('freeze', this.onPageLeave);
navigator.mediaDevices?.addEventListener('devicechange', this.handleDeviceChange);
}
Expand Down Expand Up @@ -1412,7 +1418,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
this.audioContext = undefined;
}
if (isWeb()) {
this.options.disconnectOnPageLeave && this.unregisterUnloadEvents()
if (this.options.disconnectOnPageLeave) {
this.unregisterUnloadEvents()
}
window.removeEventListener('freeze', this.onPageLeave);
navigator.mediaDevices?.removeEventListener('devicechange', this.handleDeviceChange);
}
Expand Down

0 comments on commit a40187a

Please sign in to comment.