diff --git a/src/webapp/features/cards/components/urlCardContent/UrlCardContent.tsx b/src/webapp/features/cards/components/urlCardContent/UrlCardContent.tsx index 3c0d20e9..d57587cb 100644 --- a/src/webapp/features/cards/components/urlCardContent/UrlCardContent.tsx +++ b/src/webapp/features/cards/components/urlCardContent/UrlCardContent.tsx @@ -8,8 +8,7 @@ import LinkCardContent from './LinkCardContent'; import BlueskyPost from '@/features/platforms/bluesky/components/blueskyPost/BlueskyPost'; import { Suspense } from 'react'; import { ErrorBoundary } from 'react-error-boundary'; -import { Stack, Text, Group, Alert, Anchor, Tooltip } from '@mantine/core'; -import BlueskyPlatformIcon from '@/features/platforms/bluesky/components/blueskyPlatformIcon/BlueskyPlatformIcon'; + import BlueskyPostSkeleton from '@/features/platforms/bluesky/components/blueskyPost/Skeleton.BlueskyPost'; import { useUserSettings } from '@/features/settings/lib/queries/useUserSettings'; import IframeEmbed from '@/features/platforms/common/components/IframeEmbed/IframeEmbed'; @@ -89,45 +88,13 @@ export default function UrlCardContent(props: Props) { ) { return ( { - if (error?.status === 404 || error?.error === 'NotFound') { - const platformName = - platform.type === SupportedPlatform.BLUESKY_POST - ? 'Bluesky' - : 'Blacksky'; - return ( - - - - e.stopPropagation()} - > - - - - - - - ); - } - - return ( - - ); - }} + fallback={ + + } > }> ; + if (!data) { + return ( + + + + e.stopPropagation()} + > + {platformIcon} + + + + + + ); + } + if ( !data.thread || !AppBskyFeedDefs.isThreadViewPost(data.thread) || diff --git a/src/webapp/features/platforms/bluesky/components/blueskySemblePost/BlueskySemblePost.tsx b/src/webapp/features/platforms/bluesky/components/blueskySemblePost/BlueskySemblePost.tsx index 3fb09abd..f7c4130a 100644 --- a/src/webapp/features/platforms/bluesky/components/blueskySemblePost/BlueskySemblePost.tsx +++ b/src/webapp/features/platforms/bluesky/components/blueskySemblePost/BlueskySemblePost.tsx @@ -5,7 +5,16 @@ import { getPostUriFromUrl } from '@/lib/utils/atproto'; import RichTextRenderer from '@/components/contentDisplay/richTextRenderer/RichTextRenderer'; import { detectUrlPlatform, SupportedPlatform } from '@/lib/utils/link'; import { getFormattedDate } from '@/lib/utils/time'; -import { Stack, Tooltip, Anchor, Card, Group, Box, Text } from '@mantine/core'; +import { + Stack, + Tooltip, + Anchor, + Card, + Group, + Box, + Text, + Alert, +} from '@mantine/core'; import BlueskyPlatformIcon from '../blueskyPlatformIcon/BlueskyPlatformIcon'; import PostEmbed from '../postEmbed/PostEmbed'; import ContentHider from '../contentHider/ContentHider'; @@ -32,6 +41,36 @@ export default async function BlueskySemblePost(props: Props) { const platform = detectUrlPlatform(props.url); const platformIcon = ; + if (!data) { + return ( + + }> + + + + + + + + {platformIcon} + + + + + + + + ); + } + if ( !data.thread || !AppBskyFeedDefs.isThreadViewPost(data.thread) || diff --git a/src/webapp/features/platforms/bluesky/lib/dal.ts b/src/webapp/features/platforms/bluesky/lib/dal.ts index 5beeb4dc..a628548e 100644 --- a/src/webapp/features/platforms/bluesky/lib/dal.ts +++ b/src/webapp/features/platforms/bluesky/lib/dal.ts @@ -9,11 +9,19 @@ interface Params { export const getBlueskyPost = cache(async (uri: string) => { const agent = new AtpAgent({ service: 'https://public.api.bsky.app' }); - const post = await agent.getPostThread({ - uri: uri, - depth: 0, - parentHeight: 0, - }); + let post; + try { + post = await agent.getPostThread({ + uri: uri, + depth: 0, + parentHeight: 0, + }); + } catch (err: any) { + if (err?.status === 404 || err?.error === 'NotFound') { + return null; + } + throw err; + } if (!post.success) { throw new Error('Could not load bluesky post'); diff --git a/src/webapp/next-env.d.ts b/src/webapp/next-env.d.ts index c4b7818f..9edff1c7 100644 --- a/src/webapp/next-env.d.ts +++ b/src/webapp/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import "./.next/dev/types/routes.d.ts"; +import "./.next/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.