From 11031320927ea551d46eb41d8b0124d1e05d98df Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 17 May 2026 09:52:26 +0000 Subject: [PATCH] Remove legacy Toast wrapper Deletes src/view/com/util/Toast and its LegacyToastType union. The two remaining callers (UserAddRemoveLists and PostFeedErrorMessage) and the Storybook deprecated-API demo are migrated to the canonical `#/components/Toast` API. Also picks up two prettier fixes in Toast/index.{tsx,web.tsx} from the previous commit. --- src/components/Toast/index.tsx | 3 +- src/components/Toast/index.web.tsx | 3 +- src/view/com/modals/UserAddRemoveLists.tsx | 4 +- src/view/com/posts/PostFeedErrorMessage.tsx | 4 +- src/view/com/util/Toast.tsx | 51 --------------------- src/view/screens/Storybook/Toasts.tsx | 15 ------ 6 files changed, 8 insertions(+), 72 deletions(-) delete mode 100644 src/view/com/util/Toast.tsx diff --git a/src/components/Toast/index.tsx b/src/components/Toast/index.tsx index 6f432bdda1..bb163b152d 100644 --- a/src/components/Toast/index.tsx +++ b/src/components/Toast/index.tsx @@ -107,7 +107,8 @@ export function promise( { ...options, id, - duration: type === 'pending' ? Infinity : (options?.duration ?? DURATION), + duration: + type === 'pending' ? Infinity : (options?.duration ?? DURATION), dismissible: type === 'pending' ? false : options?.dismissible, }, ) diff --git a/src/components/Toast/index.web.tsx b/src/components/Toast/index.web.tsx index 9d8cd2559c..8f2207ea3e 100644 --- a/src/components/Toast/index.web.tsx +++ b/src/components/Toast/index.web.tsx @@ -108,7 +108,8 @@ export function promise( ...options, unstyled: true, // required on web id, - duration: type === 'pending' ? Infinity : (options?.duration ?? DURATION), + duration: + type === 'pending' ? Infinity : (options?.duration ?? DURATION), dismissible: type === 'pending' ? false : options?.dismissible, }, ) diff --git a/src/view/com/modals/UserAddRemoveLists.tsx b/src/view/com/modals/UserAddRemoveLists.tsx index 1648b0ff22..be0e0ec0ee 100644 --- a/src/view/com/modals/UserAddRemoveLists.tsx +++ b/src/view/com/modals/UserAddRemoveLists.tsx @@ -24,11 +24,11 @@ import { useListMembershipRemoveMutation, } from '#/state/queries/list-memberships' import {useSession} from '#/state/session' +import * as Toast from '#/components/Toast' import {IS_ANDROID, IS_WEB, IS_WEB_MOBILE} from '#/env' import {MyLists} from '../lists/MyLists' import {Button} from '../util/forms/Button' import {Text} from '../util/text/Text' -import * as Toast from '../util/Toast' import {UserAvatar} from '../util/UserAvatar' export const snapPoints = ['fullscreen'] @@ -172,7 +172,7 @@ function ListItem({ onRemove?.(list.uri) } } catch (e) { - Toast.show(cleanError(e), 'xmark') + Toast.show(cleanError(e), {type: 'error'}) } finally { setIsProcessing(false) } diff --git a/src/view/com/posts/PostFeedErrorMessage.tsx b/src/view/com/posts/PostFeedErrorMessage.tsx index 0298ce228b..b91f4f26c5 100644 --- a/src/view/com/posts/PostFeedErrorMessage.tsx +++ b/src/view/com/posts/PostFeedErrorMessage.tsx @@ -18,11 +18,11 @@ import {type FeedDescriptor} from '#/state/queries/post-feed' import {useRemoveFeedMutation} from '#/state/queries/preferences' import {Warning_Stroke2_Corner0_Rounded as WarningIcon} from '#/components/icons/Warning' import * as Prompt from '#/components/Prompt' +import * as Toast from '#/components/Toast' import {EmptyState} from '../util/EmptyState' import {ErrorMessage} from '../util/error/ErrorMessage' import {Button} from '../util/forms/Button' import {Text} from '../util/text/Text' -import * as Toast from '../util/Toast' export enum KnownError { Block = 'Block', @@ -152,7 +152,7 @@ function FeedgenErrorMessage({ _l( msgLingui`There was an issue removing this feed. Please check your internet connection and try again.`, ), - 'exclamation-circle', + {type: 'warning'}, ) logger.error('Failed to remove feed', {message: err}) } diff --git a/src/view/com/util/Toast.tsx b/src/view/com/util/Toast.tsx deleted file mode 100644 index 639c585d01..0000000000 --- a/src/view/com/util/Toast.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import * as toast from '#/components/Toast' -import {type ToastType} from '#/components/Toast/types' - -/** - * @deprecated use {@link ToastType} and {@link toast} instead - */ -export type LegacyToastType = - | 'xmark' - | 'exclamation-circle' - | 'check' - | 'clipboard-check' - | 'circle-exclamation' - -export const convertLegacyToastType = ( - type: ToastType | LegacyToastType, -): ToastType => { - switch (type) { - // these ones are fine - case 'default': - case 'success': - case 'error': - case 'warning': - case 'info': - case 'pending': - return type - // legacy ones need conversion - case 'xmark': - return 'error' - case 'exclamation-circle': - return 'warning' - case 'check': - return 'success' - case 'clipboard-check': - return 'success' - case 'circle-exclamation': - return 'warning' - default: - return 'default' - } -} - -/** - * @deprecated use {@link toast} instead - */ -export function show( - message: string, - type: ToastType | LegacyToastType = 'default', -): void { - const convertedType = convertLegacyToastType(type) - toast.show(message, {type: convertedType}) -} diff --git a/src/view/screens/Storybook/Toasts.tsx b/src/view/screens/Storybook/Toasts.tsx index 91fe0d970c..090af02a6c 100644 --- a/src/view/screens/Storybook/Toasts.tsx +++ b/src/view/screens/Storybook/Toasts.tsx @@ -1,6 +1,5 @@ import {Pressable, View} from 'react-native' -import {show as deprecatedShow} from '#/view/com/util/Toast' import {atoms as a} from '#/alf' import {Globe_Stroke2_Corner0_Rounded as GlobeIcon} from '#/components/icons/Globe' import * as Toast from '#/components/Toast' @@ -134,20 +133,6 @@ export function Toasts() { }> - - - deprecatedShow( - `This is a test of the deprecated API`, - 'exclamation-circle', - ) - }> - - )