diff --git a/src/view/com/feeds/FeedSourceCard.tsx b/src/view/com/feeds/FeedSourceCard.tsx index 0e77f1cf3c..18e2807a84 100644 --- a/src/view/com/feeds/FeedSourceCard.tsx +++ b/src/view/com/feeds/FeedSourceCard.tsx @@ -8,29 +8,20 @@ import { import {msg, Plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {cleanError} from '#/lib/strings/errors' import {sanitizeHandle} from '#/lib/strings/handles' -import {isNative, isWeb} from '#/platform/detection' -import {useModerationOpts} from '#/state/preferences/moderation-opts' import { type FeedSourceInfo, - getFeedTypeFromUri, 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, 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 as WarningIcon} from '#/components/icons/Warning' +import {atoms as a, useTheme} from '#/alf' import {Link} from '#/components/Link' -import * as ProfileCard from '#/components/ProfileCard' import {RichText} from '#/components/RichText' import {Text} from '#/components/Typography' +import {MissingFeed} from './MissingFeed' type FeedSourceCardProps = { feedUri: string @@ -227,193 +218,3 @@ 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() - - const type = getFeedTypeFromUri(uri) - - return ( - <> - - - - - - - - - {type === 'feed' ? ( - Could not connect to feed service - ) : ( - Deleted list - )} - - - {type === 'feed' ? ( - - We could not connect to the service that provides this custom - feed. It may be temporarily unavailable and experiencing - issues, or permanently unavailable. - - ) : ( - - We could not find this list. It was probably deleted. - - )} - - - - {type === 'feed' ? ( - Feed creator - ) : ( - List creator - )} - - {profile && moderationOpts && ( - - control.close()}> - - - - - - - )} - {isProfileError && ( - - Could not find profile - - )} - {type === 'feed' && ( - <> - - Feed identifier - - - {atUri.rkey} - - - )} - {error instanceof Error && ( - <> - - Error message - - - {cleanError(error.message)} - - - )} - - {isNative && ( - - )} - - - - - ) -} diff --git a/src/view/com/feeds/MissingFeed.tsx b/src/view/com/feeds/MissingFeed.tsx new file mode 100644 index 0000000000..3d281a7316 --- /dev/null +++ b/src/view/com/feeds/MissingFeed.tsx @@ -0,0 +1,222 @@ +import {type StyleProp, View, type ViewStyle} from 'react-native' +import {AtUri} from '@atproto/api' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {cleanError} from '#/lib/strings/errors' +import {isNative, isWeb} from '#/platform/detection' +import {useModerationOpts} from '#/state/preferences/moderation-opts' +import {getFeedTypeFromUri} from '#/state/queries/feed' +import {useProfileQuery} from '#/state/queries/profile' +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 as WarningIcon} from '#/components/icons/Warning' +import * as ProfileCard from '#/components/ProfileCard' +import {Text} from '#/components/Typography' + +export function MissingFeed({ + style, + hideTopBorder, + uri, + error, +}: { + style?: StyleProp + hideTopBorder?: boolean + uri: string + error?: unknown +}) { + const t = useTheme() + const {_} = useLingui() + const control = Dialog.useDialogControl() + + const type = getFeedTypeFromUri(uri) + + return ( + <> + + + + + + + + ) +} + +function DialogInner({ + uri, + type, + error, +}: { + uri: string + type: 'feed' | 'list' + error: unknown +}) { + const control = Dialog.useDialogContext() + const t = useTheme() + const {_} = useLingui() + const atUri = new AtUri(uri) + const {data: profile, isError: isProfileError} = useProfileQuery({ + did: atUri.host, + }) + const moderationOpts = useModerationOpts() + + return ( + + + + {type === 'feed' ? ( + Could not connect to feed service + ) : ( + Deleted list + )} + + + {type === 'feed' ? ( + + We could not connect to the service that provides this custom + feed. It may be temporarily unavailable and experiencing issues, + or permanently unavailable. + + ) : ( + We could not find this list. It was probably deleted. + )} + + + + {type === 'feed' ? ( + Feed creator + ) : ( + List creator + )} + + {profile && moderationOpts && ( + + control.close()}> + + + + + + + )} + {isProfileError && ( + + Could not find profile + + )} + {type === 'feed' && ( + <> + + Feed identifier + + + {atUri.rkey} + + + )} + {error instanceof Error && ( + <> + + Error message + + + {cleanError(error.message)} + + + )} + + {isNative && ( + + )} + + + ) +}