From 0c3ae4418185059d17e30a5b5af283b54ece9b0d Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 27 Jun 2025 13:27:02 +0300 Subject: [PATCH] add handling for feeds that fail to load --- src/components/Divider.tsx | 11 +- src/view/com/feeds/FeedSourceCard.tsx | 202 ++++++++++++++++++++++- src/view/com/util/LoadingPlaceholder.tsx | 2 +- 3 files changed, 200 insertions(+), 15 deletions(-) diff --git a/src/components/Divider.tsx b/src/components/Divider.tsx index e4891aacb1..ec7a7356ad 100644 --- a/src/components/Divider.tsx +++ b/src/components/Divider.tsx @@ -1,18 +1,11 @@ import {View} from 'react-native' -import {atoms as a, flatten, useTheme, ViewStyleProp} from '#/alf' +import {atoms as a, useTheme, type ViewStyleProp} from '#/alf' export function Divider({style}: ViewStyleProp) { const t = useTheme() return ( - + ) } diff --git a/src/view/com/feeds/FeedSourceCard.tsx b/src/view/com/feeds/FeedSourceCard.tsx index 4b2db8cf63..26778ce088 100644 --- a/src/view/com/feeds/FeedSourceCard.tsx +++ b/src/view/com/feeds/FeedSourceCard.tsx @@ -9,16 +9,24 @@ import {msg, Plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {sanitizeHandle} from '#/lib/strings/handles' +import {isNative, isWeb} from '#/platform/detection' +import {useModerationOpts} from '#/state/preferences/moderation-opts' import { type FeedSourceInfo, hydrateFeedGenerator, hydrateList, useFeedSourceInfoQuery, } from '#/state/queries/feed' +import {useProfileQuery} from '#/state/queries/profile' import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder' import {UserAvatar} from '#/view/com/util/UserAvatar' -import {atoms as a, useTheme} from '#/alf' +import {atoms as a, useTheme, web} from '#/alf' +import {Button, ButtonText} from '#/components/Button' +import * as Dialog from '#/components/Dialog' +import {Divider} from '#/components/Divider' +import {Warning_Stroke2_Corner0_Rounded} from '#/components/icons/Warning' import {Link} from '#/components/Link' +import * as ProfileCard from '#/components/ProfileCard' import {RichText} from '#/components/RichText' import {Text} from '#/components/Typography' @@ -49,7 +57,7 @@ export function FeedSourceCard({ } else { feed = hydrateList(feedData) } - return + return } else { return } @@ -59,14 +67,22 @@ export function FeedSourceCardWithoutData({ feedUri, ...props }: Omit) { - const {data: feed} = useFeedSourceInfoQuery({ + const {data: feed, error} = useFeedSourceInfoQuery({ uri: feedUri, }) - return + return ( + + ) } export function FeedSourceCardLoaded({ + feedUri, feed, style, showDescription = false, @@ -74,7 +90,9 @@ export function FeedSourceCardLoaded({ showMinimalPlaceholder, hideTopBorder, link = true, + error, }: { + feedUri: string feed?: FeedSourceInfo style?: StyleProp showDescription?: boolean @@ -82,6 +100,7 @@ export function FeedSourceCardLoaded({ showMinimalPlaceholder?: boolean hideTopBorder?: boolean link?: boolean + error?: unknown }) { const t = useTheme() const {_} = useLingui() @@ -92,7 +111,18 @@ export function FeedSourceCardLoaded({ * This state also captures the scenario where a feed can't load for whatever * reason. */ - if (!feed) + if (!feed) { + if (error) { + return ( + + ) + } + return ( ) + } const inner = ( <> @@ -194,3 +225,164 @@ export function FeedSourceCardLoaded({ ) } } + +function MissingFeed({ + style, + hideTopBorder, + uri, + error, +}: { + style?: StyleProp + hideTopBorder?: boolean + uri: string + error?: unknown +}) { + const t = useTheme() + const {_} = useLingui() + const atUri = new AtUri(uri) + const {data: profile, isError: isProfileError} = useProfileQuery({ + did: atUri.host, + }) + const moderationOpts = useModerationOpts() + const control = Dialog.useDialogControl() + + return ( + <> + + + + + + + + + Could not connect to feed service + + + + We could not connect to the service that provides this custom + feed. It may be temporarily unavailable and experiencing issues, + or permanently unavailable. + + + + + Feed creator + + {profile && moderationOpts && ( + + control.close()}> + + + + + + + )} + {isProfileError && ( + + Could not find profile + + )} + + Feed identifier + + + {atUri.rkey} + + {error instanceof Error && ( + <> + + Error message + + + {error.message} + + + )} + + {isNative && ( + + )} + + + + + ) +} diff --git a/src/view/com/util/LoadingPlaceholder.tsx b/src/view/com/util/LoadingPlaceholder.tsx index 486f353f01..1b454598b8 100644 --- a/src/view/com/util/LoadingPlaceholder.tsx +++ b/src/view/com/util/LoadingPlaceholder.tsx @@ -243,7 +243,7 @@ export function FeedLoadingPlaceholder({