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.
This commit is contained in:
Claude
2026-05-17 09:52:26 +00:00
parent f03bf2a65f
commit 1103132092
6 changed files with 8 additions and 72 deletions
+2 -1
View File
@@ -107,7 +107,8 @@ export function promise<T>(
{
...options,
id,
duration: type === 'pending' ? Infinity : (options?.duration ?? DURATION),
duration:
type === 'pending' ? Infinity : (options?.duration ?? DURATION),
dismissible: type === 'pending' ? false : options?.dismissible,
},
)
+2 -1
View File
@@ -108,7 +108,8 @@ export function promise<T>(
...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,
},
)
+2 -2
View File
@@ -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)
}
+2 -2
View File
@@ -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})
}
-51
View File
@@ -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})
}
-15
View File
@@ -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() {
}>
<DefaultToast content="This is an error toast :(" type="error" />
</Pressable>
<Pressable
accessibilityRole="button"
onPress={() =>
deprecatedShow(
`This is a test of the deprecated API`,
'exclamation-circle',
)
}>
<DefaultToast
content="This is a test of the deprecated API"
type="warning"
/>
</Pressable>
</View>
</View>
)