Update toast API usage

(cherry picked from commit e370018b8ed8cdfd7675c9634058c72cb59d39de)
This commit is contained in:
Eric Bailey
2025-08-13 15:56:37 -05:00
committed by Samuel Newman
parent 336a25748e
commit 9b8fd2eb48
2 changed files with 7 additions and 19 deletions
+4 -13
View File
@@ -129,7 +129,7 @@ import {EmojiArc_Stroke2_Corner0_Rounded as EmojiSmile} from '#/components/icons
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
import {LazyQuoteEmbed} from '#/components/Post/Embed/LazyQuoteEmbed' import {LazyQuoteEmbed} from '#/components/Post/Embed/LazyQuoteEmbed'
import * as Prompt from '#/components/Prompt' import * as Prompt from '#/components/Prompt'
import {toast} from '#/components/Toast' import * as toast from '#/components/Toast'
import {Text as NewText} from '#/components/Typography' import {Text as NewText} from '#/components/Typography'
import {BottomSheetPortalProvider} from '../../../../modules/bottom-sheet' import {BottomSheetPortalProvider} from '../../../../modules/bottom-sheet'
import { import {
@@ -815,10 +815,8 @@ let ComposerPost = React.memo(function ComposerPost({
if (isNative) return // web only if (isNative) return // web only
const [mimeType] = uri.slice('data:'.length).split(';') const [mimeType] = uri.slice('data:'.length).split(';')
if (!SUPPORTED_MIME_TYPES.includes(mimeType as SupportedMimeTypes)) { if (!SUPPORTED_MIME_TYPES.includes(mimeType as SupportedMimeTypes)) {
toast.show({ toast.show(_(msg`Unsupported video type`), {
type: 'error', type: 'error',
content: _(msg`Unsupported video type`),
a11yLabel: _(msg`Unsupported video type.`),
}) })
return return
} }
@@ -1255,8 +1253,6 @@ function ComposerFooter({
dispatch, dispatch,
showAddButton, showAddButton,
onEmojiButtonPress, onEmojiButtonPress,
onError,
onSelectVideo, onSelectVideo,
onAddPost, onAddPost,
}: { }: {
@@ -1338,12 +1334,9 @@ function ComposerFooter({
} }
} }
errors.map((error, i) => { errors.map(error => {
toast.show({ toast.show(error, {
type: 'warning', type: 'warning',
content: error,
a11yLabel: error,
duration: 3e3 * (errors.length - i),
}) })
}) })
}, },
@@ -1369,9 +1362,7 @@ function ComposerFooter({
) : ( ) : (
<ToolbarWrapper style={[a.flex_row, a.align_center, a.gap_xs]}> <ToolbarWrapper style={[a.flex_row, a.align_center, a.gap_xs]}>
<SelectMediaButton <SelectMediaButton
size={images.length}
disabled={isMediaSelectionDisabled} disabled={isMediaSelectionDisabled}
setError={onError}
selectedAssetsCount={selectedAssetsCount} selectedAssetsCount={selectedAssetsCount}
onSelectAssets={onSelectAssets} onSelectAssets={onSelectAssets}
/> />
+3 -6
View File
@@ -22,12 +22,10 @@ import {atoms as a, useTheme} from '#/alf'
import {Button} from '#/components/Button' import {Button} from '#/components/Button'
import {useSheetWrapper} from '#/components/Dialog/sheet-wrapper' import {useSheetWrapper} from '#/components/Dialog/sheet-wrapper'
import {Image_Stroke2_Corner0_Rounded as ImageIcon} from '#/components/icons/Image' import {Image_Stroke2_Corner0_Rounded as ImageIcon} from '#/components/icons/Image'
import {toast} from '#/components/Toast' import * as toast from '#/components/Toast'
export type SelectMediaButtonProps = { export type SelectMediaButtonProps = {
size: number
disabled?: boolean disabled?: boolean
setError: (error: string) => void
selectedAssetsCount: number selectedAssetsCount: number
onSelectAssets: (props: { onSelectAssets: (props: {
type: AssetType type: AssetType
@@ -433,10 +431,8 @@ export function SelectMediaButton({
]) ])
if (!photoAccess && !videoAccess) { if (!photoAccess && !videoAccess) {
toast.show({ toast.show(_(msg`You need to allow access to your media library.`), {
type: 'error', type: 'error',
content: 'You need to allow access to your media library.',
a11yLabel: 'You need to allow access to your media library.',
}) })
return return
} }
@@ -459,6 +455,7 @@ export function SelectMediaButton({
await processSelectedAssets(assets) await processSelectedAssets(assets)
}, [ }, [
_,
requestPhotoAccessIfNeeded, requestPhotoAccessIfNeeded,
requestVideoAccessIfNeeded, requestVideoAccessIfNeeded,
sheetWrapper, sheetWrapper,