From 44935eeb401246a282b24f52824caae9de963177 Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Wed, 13 Nov 2024 10:14:12 +0000 Subject: [PATCH] Remove option to show non-member tiles to simplify code review --- public/locales/en-GB/app.json | 1 - src/config/Config.ts | 17 -------- src/config/ConfigOptions.ts | 2 - src/settings/SettingsModal.tsx | 19 --------- src/settings/settings.ts | 5 --- src/state/CallViewModel.ts | 73 ++-------------------------------- 6 files changed, 3 insertions(+), 114 deletions(-) diff --git a/public/locales/en-GB/app.json b/public/locales/en-GB/app.json index 1b5e8a51..dc1b6010 100644 --- a/public/locales/en-GB/app.json +++ b/public/locales/en-GB/app.json @@ -171,7 +171,6 @@ "preferences_tab_h4": "Preferences", "preferences_tab_show_hand_raised_timer_description": "Show a timer when a participant raises their hand", "preferences_tab_show_hand_raised_timer_label": "Show hand raise duration", - "show_non_member_tiles": "Show tiles for non-member media", "speaker_device_selection_label": "Speaker" }, "star_rating_input_label_one": "{{count}} stars", diff --git a/src/config/Config.ts b/src/config/Config.ts index cbe68e55..972c9e0c 100644 --- a/src/config/Config.ts +++ b/src/config/Config.ts @@ -13,7 +13,6 @@ import { ConfigOptions, ResolvedConfigOptions, } from "./ConfigOptions"; -import { showNonMemberTiles } from "../settings/settings"; export class Config { private static internalInstance: Config | undefined; @@ -33,7 +32,6 @@ export class Config { "../config.json", ).then((config) => { internalInstance.config = merge({}, DEFAULT_CONFIG, config); - internalInstance.applyConfigToSettings(); }); } return Config.internalInstance.initPromise; @@ -68,21 +66,6 @@ export class Config { return Config.get().default_server_config?.["m.homeserver"].server_name; } - private applyConfigToSettings(): void { - if (!this.config) return; - // use the value from config if it hasn't been overridden - const showNonMemberTilesSubscription = showNonMemberTiles.value.subscribe( - (val) => { - if (val === undefined && this.config) { - // we don't persist the value to local storage so that it is set from the config - // file on every startup - showNonMemberTiles.setValue(this.config.show_non_member_tiles, false); - showNonMemberTilesSubscription.unsubscribe(); - } - }, - ); - } - public config?: ResolvedConfigOptions; private initPromise?: Promise; } diff --git a/src/config/ConfigOptions.ts b/src/config/ConfigOptions.ts index 1303ebe7..ed4d5bce 100644 --- a/src/config/ConfigOptions.ts +++ b/src/config/ConfigOptions.ts @@ -136,7 +136,6 @@ export interface ResolvedConfigOptions extends ConfigOptions { enable_video: boolean; }; app_prompt: boolean; - show_non_member_tiles: boolean; } export const DEFAULT_CONFIG: ResolvedConfigOptions = { @@ -155,5 +154,4 @@ export const DEFAULT_CONFIG: ResolvedConfigOptions = { enable_video: true, }, app_prompt: true, - show_non_member_tiles: false, }; diff --git a/src/settings/SettingsModal.tsx b/src/settings/SettingsModal.tsx index 98883359..07ca5753 100644 --- a/src/settings/SettingsModal.tsx +++ b/src/settings/SettingsModal.tsx @@ -27,7 +27,6 @@ import { useSetting, developerSettingsTab as developerSettingsTabSetting, duplicateTiles as duplicateTilesSetting, - showNonMemberTiles as showNonMemberTilesSetting, useOptInAnalytics, soundEffectVolumeSetting, } from "./settings"; @@ -71,10 +70,6 @@ export const SettingsModal: FC = ({ ); const [duplicateTiles, setDuplicateTiles] = useSetting(duplicateTilesSetting); - const [showNonMemberTiles, setShowNonMemberTiles] = useSetting( - showNonMemberTilesSetting, - ); - // Generate a `SelectInput` with a list of devices for a given device kind. const generateDeviceSelection = ( devices: MediaDevice, @@ -258,20 +253,6 @@ export const SettingsModal: FC = ({ )} /> - - ): void => { - setShowNonMemberTiles(event.target.checked); - }, - [setShowNonMemberTiles], - )} - /> - ), }; diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 71112bc2..4eb2bcaa 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -77,11 +77,6 @@ export const developerSettingsTab = new Setting( export const duplicateTiles = new Setting("duplicate-tiles", 0); -export const showNonMemberTiles = new Setting( - "show-non-member-tiles", - undefined, -); - export const audioInput = new Setting( "audio-input", undefined, diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index c408c348..f3791013 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -67,7 +67,7 @@ import { } from "./MediaViewModel"; import { accumulate, finalizeValue } from "../utils/observable"; import { ObservableScope } from "./ObservableScope"; -import { duplicateTiles, showNonMemberTiles } from "../settings/settings"; +import { duplicateTiles } from "../settings/settings"; import { isFirefox } from "../Platform"; import { setPipEnabled } from "../controls"; import { GridTileViewModel, SpotlightTileViewModel } from "./TileViewModel"; @@ -439,7 +439,6 @@ export class CallViewModel extends ViewModel { this.matrixRTCSession, MatrixRTCSessionEvent.MembershipsChanged, ).pipe(startWith(null)), - showNonMemberTiles.value, ]).pipe( scan( ( @@ -449,7 +448,6 @@ export class CallViewModel extends ViewModel { { participant: localParticipant }, duplicateTiles, _membershipsChanged, - showNonMemberTiles, ], ) => { const newItems = new Map( @@ -478,20 +476,12 @@ export class CallViewModel extends ViewModel { } for (let i = 0; i < 1 + duplicateTiles; i++) { const indexedMediaId = `${mediaId}:${i}`; - let prevMedia = prevItems.get(indexedMediaId); + const prevMedia = prevItems.get(indexedMediaId); if (prevMedia && prevMedia instanceof UserMedia) { if (prevMedia.participant.value !== participant) { // Update the BahviourSubject in the UserMedia. prevMedia.participant.next(participant); } - if (prevMedia.vm.member === undefined) { - // We have a previous media created because of the `debugShowNonMember` flag. - // In this case we actually replace the media item. - // This "hack" never occurs if we do not use the `debugShowNonMember` debugging - // option and if we always find a room member for each rtc member (which also - // only fails if we have a fundamental problem) - prevMedia = undefined; - } } yield [ indexedMediaId, @@ -528,64 +518,7 @@ export class CallViewModel extends ViewModel { }.bind(this)(), ); - // Generate non member items (items without a corresponding MatrixRTC member) - // Those items should not be rendered, they are participants in livekit that do not have a corresponding - // matrix rtc members. This cannot be any good: - // - A malicious user impersonates someone - // - Someone injects abusive content - // - The user cannot have encryption keys so it makes no sense to participate - // We can only trust users that have a matrixRTC member event. - // - // This is still available as a debug option. This can be useful - // - If one wants to test scalability using the livekit cli. - // - If an experimental project does not yet do the matrixRTC bits. - // - If someone wants to debug if the LK connection works but matrixRTC room state failed to arrive. - const debugShowNonMember = showNonMemberTiles; //Config.get().show_non_member_tiles; - const newNonMemberItems = debugShowNonMember - ? new Map( - function* (this: CallViewModel): Iterable<[string, MediaItem]> { - for (const participant of remoteParticipants) { - for (let i = 0; i < 1 + duplicateTiles; i++) { - const maybeNonMemberParticipantId = - participant.identity + ":" + i; - if (!newItems.has(maybeNonMemberParticipantId)) { - const nonMemberId = maybeNonMemberParticipantId; - yield [ - nonMemberId, - // We create UserMedia with or without a participant. - // This will be the initial value of a BehaviourSubject. - // Once a participant appears we will update the BehaviourSubject. (see above) - prevItems.get(nonMemberId) ?? - new UserMedia( - nonMemberId, - undefined, - participant, - this.encryptionSystem, - this.livekitRoom, - false, - ), - ]; - } - } - } - }.bind(this)(), - ) - : new Map(); - if (newNonMemberItems.size > 0) { - logger.debug("Added NonMember items: ", newNonMemberItems); - } - const newNonMemberItemCount = - newNonMemberItems.size / (1 + duplicateTiles); - if (this.nonMemberItemCount.value !== newNonMemberItemCount) - this.nonMemberItemCount.next(newNonMemberItemCount); - - const combinedNew = new Map([ - ...newNonMemberItems.entries(), - ...newItems.entries(), - ]); - - for (const [id, t] of prevItems) if (!combinedNew.has(id)) t.destroy(); - return combinedNew; + return newItems; }, new Map(), ),