From bc43c25395ccc06be7d8aff12110a633996a055d Mon Sep 17 00:00:00 2001 From: sphinxrave <62570796+sphinxrave@users.noreply.github.com> Date: Sat, 28 Dec 2024 17:50:10 -0800 Subject: [PATCH] show collab members in placeholder card --- .../components/video/VideoCardPlaceholder.tsx | 248 +++++++++--------- packages/react/src/store/settings.ts | 13 + 2 files changed, 144 insertions(+), 117 deletions(-) diff --git a/packages/react/src/components/video/VideoCardPlaceholder.tsx b/packages/react/src/components/video/VideoCardPlaceholder.tsx index 250279cc3..082a6d3b4 100644 --- a/packages/react/src/components/video/VideoCardPlaceholder.tsx +++ b/packages/react/src/components/video/VideoCardPlaceholder.tsx @@ -20,6 +20,7 @@ import { import { userAtom } from "@/store/auth"; import { VideoCardType } from "./VideoCard"; import { VideoCardCountdownToLive } from "./VideoCardCountdownToLive"; +import { useNamePrefFn } from "@/store/settings"; export default function VideoCardPlaceholder({ open, @@ -34,6 +35,7 @@ export default function VideoCardPlaceholder({ const isSmall = useAtomValue(siteIsSmallAtom); const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); const user = useAtomValue(userAtom); + const nameFn = useNamePrefFn(); const thumbnailSrc = video.type === "placeholder" && video.thumbnail @@ -52,131 +54,143 @@ export default function VideoCardPlaceholder({ }; const content = useMemo( - () => ( -
- -
-

{video.title}

-
-
- {video.channel.name} -
-
-
- + () => + open && ( +
+ +
+

{video.title}

+
+
+
+ {nameFn(video.channel)} +
+ {video.mentions && + video.mentions.map((mention) => ( +
+
+ {nameFn(mention)} +
+ ))} +
+
+
+ +
-
-
- -
-
- {t("component.placeholderVideo.creditTitleText")}{" "} - {video.credits?.discord && - t("component.placeholderVideo.discordCredit", { - user: video.credits.discord.user, - guild: ( +
+ +
+
+ {t("component.placeholderVideo.creditTitleText")}{" "} + {video.credits?.discord && + t("component.placeholderVideo.discordCredit", { + user: video.credits.discord.user, + guild: ( + + +
+ {video.credits.discord.guildName} + + + ), + })} + {video.credits?.datasource && ( + + {t("component.placeholderVideo.datasourceCredit", { + 0: video.credits.datasource.name, + })} - -
- {video.credits.discord.guildName} + +
+ {video.credits.datasource.link} - ), - })} - {video.credits?.datasource && ( - - {t("component.placeholderVideo.datasourceCredit", { - 0: video.credits.datasource.name, - })} - - -
- {video.credits.datasource.link} - - - - )} - {video.credits?.bot && ( - - {t("component.placeholderVideo.botCredit", { - 0: video.credits.bot.name, - 1: video.credits.bot.user, - })} - - -
- {video.credits.bot.link} - - - - )} - {video.credits?.editor && ( - - {t("component.placeholderVideo.editorCredit", { - 0: video.credits.editor.name, - })} - + + )} + {video.credits?.bot && ( + + {t("component.placeholderVideo.botCredit", { + 0: video.credits.bot.name, + 1: video.credits.bot.user, + })} + + + {video.credits.bot.link} +
+ + + + )} + {video.credits?.editor && ( + + {t("component.placeholderVideo.editorCredit", { + 0: video.credits.editor.name, + })} + + )} +
+ {user && user.role !== "user" && ( +
+ + {video.id} + + + + + + + + + Are you sure? + + This action cannot be undone. + + + + Cancel + + Delete + + + + +
)}
- {user && user.role !== "user" && ( -
- {video.id} - - - - - - - - Are you sure? - - This action cannot be undone. - - - - Cancel - - Delete - - - - -
- )}
-
- ), - [thumbnailSrc, video, t, user, showDeleteConfirm], + ), + [open, thumbnailSrc, video, nameFn, t, user, showDeleteConfirm], ); if (isSmall) { diff --git a/packages/react/src/store/settings.ts b/packages/react/src/store/settings.ts index 9fa612572..ff3cac157 100644 --- a/packages/react/src/store/settings.ts +++ b/packages/react/src/store/settings.ts @@ -1,6 +1,7 @@ import { GET_ON_INIT } from "@/lib/consts"; import { atom, useAtomValue } from "jotai"; import { atomWithStorage } from "jotai/utils"; +import { useCallback } from "react"; // Define the interface for the new settings state export interface HolodexSettings { @@ -61,6 +62,18 @@ export function usePreferredName({ return useEnglishName ? english_name || name : name; } +export function useNamePrefFn() { + const useEnglishName = useAtomValue(englishNameAtom); + + const prefFn = useCallback( + ({ name, english_name }: { name?: string; english_name?: string }) => + useEnglishName ? english_name || name : name, + [useEnglishName], + ); + + return prefFn; +} + export const clipLanguageAtom = atom( (get) => get(settingsAtom).clipLanguage, (get, set, newValue: string[]) => {