Create codemod for updating Toast calls to v2 (#10045)

This commit is contained in:
DS Boyce
2026-03-12 11:35:58 -07:00
committed by GitHub
parent 9c9970f680
commit 35cb2bcf94
62 changed files with 422 additions and 171 deletions
@@ -56,7 +56,6 @@ import {
} from '#/state/queries/threadgate'
import {useRequireAuth, useSession} from '#/state/session'
import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
import * as Toast from '#/view/com/util/Toast'
import {useDialogControl} from '#/components/Dialog'
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
import {
@@ -93,6 +92,7 @@ import {
useReportDialogControl,
} from '#/components/moderation/ReportDialog'
import * as Prompt from '#/components/Prompt'
import * as Toast from '#/components/Toast'
import {useAnalytics} from '#/analytics'
import {IS_INTERNAL} from '#/env'
import * as bsky from '#/types/bsky'
@@ -216,7 +216,9 @@ let PostMenuItems = ({
},
e => {
logger.error('Failed to delete post', {message: e})
Toast.show(l`Failed to delete post, please try again`, 'xmark')
Toast.show(l`Failed to delete post, please try again`, {
type: 'error',
})
},
)
}
@@ -246,7 +248,9 @@ let PostMenuItems = ({
const e = err as Error
if (e?.name !== 'AbortError') {
logger.error('Failed to toggle thread mute', {message: e})
Toast.show(l`Failed to toggle thread mute, please try again`, 'xmark')
Toast.show(l`Failed to toggle thread mute, please try again`, {
type: 'error',
})
}
}
}
@@ -265,7 +269,9 @@ let PostMenuItems = ({
const str = richTextToString(richText, true)
void Clipboard.setStringAsync(str)
Toast.show(l`Copied to clipboard`, 'clipboard-check')
Toast.show(l`Copied to clipboard`, {
type: 'success',
})
}
const onPressTranslate = () => {
@@ -434,7 +440,9 @@ let PostMenuItems = ({
const e = err as Error
if (e?.name !== 'AbortError') {
logger.error('Failed to block account', {message: e})
Toast.show(l`There was an issue! ${e.toString()}`, 'xmark')
Toast.show(l`There was an issue! ${e.toString()}`, {
type: 'error',
})
}
} finally {
ax.metric('postMenu:blockAccount', {
@@ -455,7 +463,9 @@ let PostMenuItems = ({
const e = err as Error
if (e?.name !== 'AbortError') {
logger.error('Failed to unmute account', {message: e})
Toast.show(l`There was an issue! ${e.toString()}`, 'xmark')
Toast.show(l`There was an issue! ${e.toString()}`, {
type: 'error',
})
}
} finally {
ax.metric('postMenu:unmuteAccount', {
@@ -473,7 +483,9 @@ let PostMenuItems = ({
const e = err as Error
if (e?.name !== 'AbortError') {
logger.error('Failed to mute account', {message: e})
Toast.show(l`There was an issue! ${e.toString()}`, 'xmark')
Toast.show(l`There was an issue! ${e.toString()}`, {
type: 'error',
})
}
} finally {
ax.metric('postMenu:muteAccount', {
@@ -12,7 +12,6 @@ import {shareText, shareUrl} from '#/lib/sharing'
import {toShareUrl} from '#/lib/strings/url-helpers'
import {useProfileShadow} from '#/state/cache/profile-shadow'
import {useSession} from '#/state/session'
import * as Toast from '#/view/com/util/Toast'
import {atoms as a} from '#/alf'
import {Admonition} from '#/components/Admonition'
import {useDialogControl} from '#/components/Dialog'
@@ -22,6 +21,7 @@ import {ChainLink_Stroke2_Corner0_Rounded as ChainLinkIcon} from '#/components/i
import {Clipboard_Stroke2_Corner2_Rounded as ClipboardIcon} from '#/components/icons/Clipboard'
import {PaperPlane_Stroke2_Corner0_Rounded as PaperPlaneIcon} from '#/components/icons/PaperPlane'
import * as Menu from '#/components/Menu'
import * as Toast from '#/components/Toast'
import {useAgeAssurance} from '#/ageAssurance'
import {useAnalytics} from '#/analytics'
import {IS_IOS} from '#/env'
@@ -71,7 +71,9 @@ let ShareMenuItems = ({
} else {
await ExpoClipboard.setStringAsync(url)
}
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
Toast.show(_(msg`Copied to clipboard`), {
type: 'success',
})
onShareProp()
}
+10 -4
View File
@@ -24,11 +24,11 @@ import {
ProgressGuideAction,
useProgressGuideControls,
} from '#/state/shell/progress-guide'
import * as Toast from '#/view/com/util/Toast'
import {atoms as a, useBreakpoints} from '#/alf'
import {Reply as Bubble} from '#/components/icons/Reply'
import {useFormatPostStatCount} from '#/components/PostControls/util'
import * as Skele from '#/components/Skeleton'
import * as Toast from '#/components/Toast'
import {useAnalytics} from '#/analytics'
import {BookmarkButton} from './BookmarkButton'
import {
@@ -106,7 +106,9 @@ let PostControls = ({
const onPressToggleLike = async () => {
if (isBlocked) {
Toast.show(l`Cannot interact with a blocked user`, 'exclamation-circle')
Toast.show(l`Cannot interact with a blocked user`, {
type: 'warning',
})
return
}
@@ -135,7 +137,9 @@ let PostControls = ({
const onRepost = async () => {
if (isBlocked) {
Toast.show(l`Cannot interact with a blocked user`, 'exclamation-circle')
Toast.show(l`Cannot interact with a blocked user`, {
type: 'warning',
})
return
}
@@ -161,7 +165,9 @@ let PostControls = ({
const onQuote = () => {
if (isBlocked) {
Toast.show(l`Cannot interact with a blocked user`, 'exclamation-circle')
Toast.show(l`Cannot interact with a blocked user`, {
type: 'warning',
})
return
}