From 00d8100dfe15ac02a38ad09a9467b3a582f2ef3d Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 1 Aug 2024 15:46:14 -0400 Subject: [PATCH] Show your own name on your tile Instead of the word "You". --- public/locales/en-GB/app.json | 1 - src/state/MediaViewModel.ts | 21 ++------------------- src/tile/GridTile.tsx | 24 +++++++++++++++--------- src/tile/MediaView.tsx | 4 +--- src/tile/SpotlightTile.tsx | 6 ++---- 5 files changed, 20 insertions(+), 36 deletions(-) diff --git a/public/locales/en-GB/app.json b/public/locales/en-GB/app.json index 0dbebf381..58c05f2b8 100644 --- a/public/locales/en-GB/app.json +++ b/public/locales/en-GB/app.json @@ -161,7 +161,6 @@ "exit_full_screen": "Exit full screen", "full_screen": "Full screen", "mute_for_me": "Mute for me", - "sfu_participant_local": "You", "volume": "Volume" } } diff --git a/src/state/MediaViewModel.ts b/src/state/MediaViewModel.ts index 8ad565e42..197f0341a 100644 --- a/src/state/MediaViewModel.ts +++ b/src/state/MediaViewModel.ts @@ -45,28 +45,14 @@ import { startWith, switchMap, } from "rxjs"; -import { useTranslation } from "react-i18next"; import { useEffect } from "react"; import { ViewModel } from "./ViewModel"; import { useReactiveState } from "../useReactiveState"; import { alwaysShowSelf } from "../settings/settings"; -export interface NameData { - /** - * The display name of the participant. - */ - displayName: string; - /** - * The text to be shown on the participant's name tag. - */ - nameTag: string; -} - // TODO: Move this naming logic into the view model -export function useNameData(vm: MediaViewModel): NameData { - const { t } = useTranslation(); - +export function useDisplayName(vm: MediaViewModel): string { const [displayName, setDisplayName] = useReactiveState( () => vm.member?.rawDisplayName ?? "[👻]", [vm.member], @@ -83,11 +69,8 @@ export function useNameData(vm: MediaViewModel): NameData { }; } }, [vm.member, setDisplayName]); - const nameTag = vm.local - ? t("video_tile.sfu_participant_local") - : displayName; - return { displayName, nameTag }; + return displayName; } function observeTrackReference( diff --git a/src/tile/GridTile.tsx b/src/tile/GridTile.tsx index dbaadc1b9..e87c506ec 100644 --- a/src/tile/GridTile.tsx +++ b/src/tile/GridTile.tsx @@ -46,7 +46,7 @@ import { useObservableEagerState } from "observable-hooks"; import styles from "./GridTile.module.css"; import { UserMediaViewModel, - useNameData, + useDisplayName, LocalUserMediaViewModel, RemoteUserMediaViewModel, } from "../state/MediaViewModel"; @@ -60,7 +60,6 @@ interface TileProps { targetWidth: number; targetHeight: number; displayName: string; - nameTag: string; showSpeakingIndicators: boolean; } @@ -79,7 +78,7 @@ const UserMediaTile = forwardRef( menuStart, menuEnd, className, - nameTag, + displayName, ...props }, ref, @@ -134,12 +133,12 @@ const UserMediaTile = forwardRef( className={styles.muteIcon} /> } - nameTag={nameTag} + displayName={displayName} primaryButton={ @@ -156,7 +155,7 @@ const UserMediaTile = forwardRef( ); return ( - + {menu} ); @@ -282,7 +281,7 @@ interface GridTileProps { export const GridTile = forwardRef( ({ vm, onOpenProfile, ...props }, ref) => { - const nameData = useNameData(vm); + const displayName = useDisplayName(vm); if (vm instanceof LocalUserMediaViewModel) { return ( @@ -290,12 +289,19 @@ export const GridTile = forwardRef( ref={ref} vm={vm} onOpenProfile={onOpenProfile} + displayName={displayName} {...props} - {...nameData} /> ); } else { - return ; + return ( + + ); } }, ); diff --git a/src/tile/MediaView.tsx b/src/tile/MediaView.tsx index 9fe086438..e30bdb8cd 100644 --- a/src/tile/MediaView.tsx +++ b/src/tile/MediaView.tsx @@ -39,7 +39,6 @@ interface Props extends ComponentProps { videoEnabled: boolean; unencryptedWarning: boolean; nameTagLeadingIcon?: ReactNode; - nameTag: string; displayName: string; primaryButton?: ReactNode; } @@ -58,7 +57,6 @@ export const MediaView = forwardRef( videoEnabled, unencryptedWarning, nameTagLeadingIcon, - nameTag, displayName, primaryButton, ...props @@ -100,7 +98,7 @@ export const MediaView = forwardRef(
{nameTagLeadingIcon} - {nameTag} + {displayName} {unencryptedWarning && ( ( ({ vm, targetWidth, targetHeight, intersectionObserver, snap }, theirRef) => { const ourRef = useRef(null); const ref = useMergedRefs(ourRef, theirRef); - const { displayName, nameTag } = useNameData(vm); + const displayName = useDisplayName(vm); const video = useObservableEagerState(vm.video); const unencryptedWarning = useObservableEagerState(vm.unencryptedWarning); @@ -153,7 +152,6 @@ const SpotlightItem = forwardRef( video, member: vm.member, unencryptedWarning, - nameTag, displayName, };