Skip to content

Commit

Permalink
Fix broken media navs;
Browse files Browse the repository at this point in the history
  • Loading branch information
stef-coenen committed Jan 9, 2025
1 parent 189216a commit dccf4fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export const CommunityMediaGallery = ({

const CustomOdinImage = ({
className,
previewThumbnail,
...props
}: { className?: string; previewThumbnail?: EmbeddedThumb } & ImageSource) => {
const dotYouClient = useDotYouClientContext();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <MediaGallery odinId={odinId} communityId={communityId} msg={msg} />;
Expand All @@ -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`}
/>
Expand Down
6 changes: 4 additions & 2 deletions packages/common/common-app/src/helpers/richTextHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ export const trimRichText = (richText: RichText | undefined): RichText | undefin

const trimmed: RichText = [];
const trimNode = (node: Record<string, unknown>): Record<string, unknown> => {
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,
Expand Down

0 comments on commit dccf4fb

Please sign in to comment.