mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-21 00:28:08 +08:00
Remove option to show non-member tiles to simplify code review
This commit is contained in:
parent
83514212cd
commit
44935eeb40
@ -171,7 +171,6 @@
|
|||||||
"preferences_tab_h4": "Preferences",
|
"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_description": "Show a timer when a participant raises their hand",
|
||||||
"preferences_tab_show_hand_raised_timer_label": "Show hand raise duration",
|
"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"
|
"speaker_device_selection_label": "Speaker"
|
||||||
},
|
},
|
||||||
"star_rating_input_label_one": "{{count}} stars",
|
"star_rating_input_label_one": "{{count}} stars",
|
||||||
|
@ -13,7 +13,6 @@ import {
|
|||||||
ConfigOptions,
|
ConfigOptions,
|
||||||
ResolvedConfigOptions,
|
ResolvedConfigOptions,
|
||||||
} from "./ConfigOptions";
|
} from "./ConfigOptions";
|
||||||
import { showNonMemberTiles } from "../settings/settings";
|
|
||||||
|
|
||||||
export class Config {
|
export class Config {
|
||||||
private static internalInstance: Config | undefined;
|
private static internalInstance: Config | undefined;
|
||||||
@ -33,7 +32,6 @@ export class Config {
|
|||||||
"../config.json",
|
"../config.json",
|
||||||
).then((config) => {
|
).then((config) => {
|
||||||
internalInstance.config = merge({}, DEFAULT_CONFIG, config);
|
internalInstance.config = merge({}, DEFAULT_CONFIG, config);
|
||||||
internalInstance.applyConfigToSettings();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Config.internalInstance.initPromise;
|
return Config.internalInstance.initPromise;
|
||||||
@ -68,21 +66,6 @@ export class Config {
|
|||||||
return Config.get().default_server_config?.["m.homeserver"].server_name;
|
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;
|
public config?: ResolvedConfigOptions;
|
||||||
private initPromise?: Promise<void>;
|
private initPromise?: Promise<void>;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,6 @@ export interface ResolvedConfigOptions extends ConfigOptions {
|
|||||||
enable_video: boolean;
|
enable_video: boolean;
|
||||||
};
|
};
|
||||||
app_prompt: boolean;
|
app_prompt: boolean;
|
||||||
show_non_member_tiles: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_CONFIG: ResolvedConfigOptions = {
|
export const DEFAULT_CONFIG: ResolvedConfigOptions = {
|
||||||
@ -155,5 +154,4 @@ export const DEFAULT_CONFIG: ResolvedConfigOptions = {
|
|||||||
enable_video: true,
|
enable_video: true,
|
||||||
},
|
},
|
||||||
app_prompt: true,
|
app_prompt: true,
|
||||||
show_non_member_tiles: false,
|
|
||||||
};
|
};
|
||||||
|
@ -27,7 +27,6 @@ import {
|
|||||||
useSetting,
|
useSetting,
|
||||||
developerSettingsTab as developerSettingsTabSetting,
|
developerSettingsTab as developerSettingsTabSetting,
|
||||||
duplicateTiles as duplicateTilesSetting,
|
duplicateTiles as duplicateTilesSetting,
|
||||||
showNonMemberTiles as showNonMemberTilesSetting,
|
|
||||||
useOptInAnalytics,
|
useOptInAnalytics,
|
||||||
soundEffectVolumeSetting,
|
soundEffectVolumeSetting,
|
||||||
} from "./settings";
|
} from "./settings";
|
||||||
@ -71,10 +70,6 @@ export const SettingsModal: FC<Props> = ({
|
|||||||
);
|
);
|
||||||
const [duplicateTiles, setDuplicateTiles] = useSetting(duplicateTilesSetting);
|
const [duplicateTiles, setDuplicateTiles] = useSetting(duplicateTilesSetting);
|
||||||
|
|
||||||
const [showNonMemberTiles, setShowNonMemberTiles] = useSetting(
|
|
||||||
showNonMemberTilesSetting,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Generate a `SelectInput` with a list of devices for a given device kind.
|
// Generate a `SelectInput` with a list of devices for a given device kind.
|
||||||
const generateDeviceSelection = (
|
const generateDeviceSelection = (
|
||||||
devices: MediaDevice,
|
devices: MediaDevice,
|
||||||
@ -258,20 +253,6 @@ export const SettingsModal: FC<Props> = ({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
<FieldRow>
|
|
||||||
<InputField
|
|
||||||
id="showNonMemberTiles"
|
|
||||||
type="checkbox"
|
|
||||||
label={t("settings.show_non_member_tiles")}
|
|
||||||
checked={!!showNonMemberTiles}
|
|
||||||
onChange={useCallback(
|
|
||||||
(event: ChangeEvent<HTMLInputElement>): void => {
|
|
||||||
setShowNonMemberTiles(event.target.checked);
|
|
||||||
},
|
|
||||||
[setShowNonMemberTiles],
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</FieldRow>
|
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
@ -77,11 +77,6 @@ export const developerSettingsTab = new Setting(
|
|||||||
|
|
||||||
export const duplicateTiles = new Setting("duplicate-tiles", 0);
|
export const duplicateTiles = new Setting("duplicate-tiles", 0);
|
||||||
|
|
||||||
export const showNonMemberTiles = new Setting<boolean | undefined>(
|
|
||||||
"show-non-member-tiles",
|
|
||||||
undefined,
|
|
||||||
);
|
|
||||||
|
|
||||||
export const audioInput = new Setting<string | undefined>(
|
export const audioInput = new Setting<string | undefined>(
|
||||||
"audio-input",
|
"audio-input",
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -67,7 +67,7 @@ import {
|
|||||||
} from "./MediaViewModel";
|
} from "./MediaViewModel";
|
||||||
import { accumulate, finalizeValue } from "../utils/observable";
|
import { accumulate, finalizeValue } from "../utils/observable";
|
||||||
import { ObservableScope } from "./ObservableScope";
|
import { ObservableScope } from "./ObservableScope";
|
||||||
import { duplicateTiles, showNonMemberTiles } from "../settings/settings";
|
import { duplicateTiles } from "../settings/settings";
|
||||||
import { isFirefox } from "../Platform";
|
import { isFirefox } from "../Platform";
|
||||||
import { setPipEnabled } from "../controls";
|
import { setPipEnabled } from "../controls";
|
||||||
import { GridTileViewModel, SpotlightTileViewModel } from "./TileViewModel";
|
import { GridTileViewModel, SpotlightTileViewModel } from "./TileViewModel";
|
||||||
@ -439,7 +439,6 @@ export class CallViewModel extends ViewModel {
|
|||||||
this.matrixRTCSession,
|
this.matrixRTCSession,
|
||||||
MatrixRTCSessionEvent.MembershipsChanged,
|
MatrixRTCSessionEvent.MembershipsChanged,
|
||||||
).pipe(startWith(null)),
|
).pipe(startWith(null)),
|
||||||
showNonMemberTiles.value,
|
|
||||||
]).pipe(
|
]).pipe(
|
||||||
scan(
|
scan(
|
||||||
(
|
(
|
||||||
@ -449,7 +448,6 @@ export class CallViewModel extends ViewModel {
|
|||||||
{ participant: localParticipant },
|
{ participant: localParticipant },
|
||||||
duplicateTiles,
|
duplicateTiles,
|
||||||
_membershipsChanged,
|
_membershipsChanged,
|
||||||
showNonMemberTiles,
|
|
||||||
],
|
],
|
||||||
) => {
|
) => {
|
||||||
const newItems = new Map(
|
const newItems = new Map(
|
||||||
@ -478,20 +476,12 @@ export class CallViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
for (let i = 0; i < 1 + duplicateTiles; i++) {
|
for (let i = 0; i < 1 + duplicateTiles; i++) {
|
||||||
const indexedMediaId = `${mediaId}:${i}`;
|
const indexedMediaId = `${mediaId}:${i}`;
|
||||||
let prevMedia = prevItems.get(indexedMediaId);
|
const prevMedia = prevItems.get(indexedMediaId);
|
||||||
if (prevMedia && prevMedia instanceof UserMedia) {
|
if (prevMedia && prevMedia instanceof UserMedia) {
|
||||||
if (prevMedia.participant.value !== participant) {
|
if (prevMedia.participant.value !== participant) {
|
||||||
// Update the BahviourSubject in the UserMedia.
|
// Update the BahviourSubject in the UserMedia.
|
||||||
prevMedia.participant.next(participant);
|
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 [
|
yield [
|
||||||
indexedMediaId,
|
indexedMediaId,
|
||||||
@ -528,64 +518,7 @@ export class CallViewModel extends ViewModel {
|
|||||||
}.bind(this)(),
|
}.bind(this)(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Generate non member items (items without a corresponding MatrixRTC member)
|
return newItems;
|
||||||
// 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;
|
|
||||||
},
|
},
|
||||||
new Map<string, MediaItem>(),
|
new Map<string, MediaItem>(),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user