From dccf4fbb84b67d343e5e9d47c3010ece417728ee Mon Sep 17 00:00:00 2001 From: Stef Coenen Date: Thu, 9 Jan 2025 14:38:35 +0100 Subject: [PATCH] Fix broken media navs; --- .../Message/detail/CommunityMediaGallery.tsx | 2 ++ .../Community/Message/item/CommunityMedia.tsx | 13 ++++++++----- .../common/common-app/src/helpers/richTextHelper.ts | 6 ++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/apps/community-app/src/components/Community/Message/detail/CommunityMediaGallery.tsx b/packages/apps/community-app/src/components/Community/Message/detail/CommunityMediaGallery.tsx index 9ee24233a..f45bd25a2 100644 --- a/packages/apps/community-app/src/components/Community/Message/detail/CommunityMediaGallery.tsx +++ b/packages/apps/community-app/src/components/Community/Message/detail/CommunityMediaGallery.tsx @@ -178,6 +178,7 @@ export const CommunityMediaGallery = ({ const CustomOdinImage = ({ className, + previewThumbnail, ...props }: { className?: string; previewThumbnail?: EmbeddedThumb } & ImageSource) => { const dotYouClient = useDotYouClientContext(); @@ -202,6 +203,7 @@ const CustomOdinImage = ({ className={`absolute inset-0 h-full w-full max-w-none object-contain object-center transition-opacity delay-500 ${finalLoaded ? 'opacity-0' : 'opacity-100'}`} dotYouClient={dotYouClient} {...props} + previewThumbnail={previewThumbnail} blur="auto" onLoad={(naturalSize: ImageSize | undefined) => { setTinyLoaded(true); diff --git a/packages/apps/community-app/src/components/Community/Message/item/CommunityMedia.tsx b/packages/apps/community-app/src/components/Community/Message/item/CommunityMedia.tsx index 15c95ced3..f431da64b 100644 --- a/packages/apps/community-app/src/components/Community/Message/item/CommunityMedia.tsx +++ b/packages/apps/community-app/src/components/Community/Message/item/CommunityMedia.tsx @@ -40,7 +40,7 @@ export const CommunityMedia = ({ ); const isGallery = payloads && payloads.length >= 2; const navigate = useNavigate(); - const { odinKey, communityKey, channelKey } = useParams(); + const { odinKey, communityKey, channelKey, threadKey } = useParams(); if (!payloads?.length) return null; if (isGallery) return ; @@ -54,11 +54,14 @@ export const CommunityMedia = ({ fileLastModified={msg.fileMetadata.updated} payload={payloads[0]} fit={'contain'} - onClick={() => + onClick={() => { + const rootPath = `${COMMUNITY_ROOT_PATH}/${odinKey}/${communityKey}/${channelKey || msg.fileMetadata.appData.content.channelId}`; navigate( - `${COMMUNITY_ROOT_PATH}/${odinKey}/${communityKey}/${channelKey || msg.fileMetadata.appData.content.channelId}/${msg.fileMetadata.appData.uniqueId}/${payloads[0].key}` - ) - } + threadKey + ? `${rootPath}/${threadKey}/thread/${msg.fileMetadata.appData.uniqueId}/${payloads[0].key}` + : `${rootPath}/${msg.fileMetadata.appData.uniqueId}/${payloads[0].key}` + ); + }} previewThumbnail={isGallery ? undefined : msg.fileMetadata.appData.previewThumbnail} className={`my-1 max-h-[35rem] max-w-xs overflow-hidden rounded-lg`} /> diff --git a/packages/common/common-app/src/helpers/richTextHelper.ts b/packages/common/common-app/src/helpers/richTextHelper.ts index 4acfa8f9e..a3a4b6cef 100644 --- a/packages/common/common-app/src/helpers/richTextHelper.ts +++ b/packages/common/common-app/src/helpers/richTextHelper.ts @@ -86,8 +86,10 @@ export const trimRichText = (richText: RichText | undefined): RichText | undefin const trimmed: RichText = []; const trimNode = (node: Record): Record => { - const newText = (typeof node.text === 'string' ? node.text?.trim() : undefined) ?? undefined; - const newValue = (typeof node.value === 'string' ? node.value?.trim() : undefined) ?? undefined; + const newText = + (node && typeof node.text === 'string' ? node.text?.trim() : undefined) ?? undefined; + const newValue = + (node && typeof node.value === 'string' ? node.value?.trim() : undefined) ?? undefined; return { ...node,