Add context for toast messages (#7902)

* add context for toast

* add
This commit is contained in:
Minseo Lee
2025-03-07 02:46:09 +09:00
committed by GitHub
parent 29eef6188a
commit a7db0bac6f
22 changed files with 64 additions and 48 deletions
@@ -183,7 +183,7 @@ let PostDropdownMenuItems = ({
const onDeletePost = React.useCallback(() => {
deletePostMutate({uri: postUri}).then(
() => {
Toast.show(_(msg`Post deleted`))
Toast.show(_(msg({message: 'Post deleted', context: 'toast'})))
const route = getCurrentRoute(navigation.getState())
if (route.name === 'PostThread') {
@@ -274,7 +274,7 @@ let PostDropdownMenuItems = ({
item: postUri,
feedContext: postFeedContext,
})
Toast.show(_(msg`Feedback sent!`))
Toast.show(_(msg({message: 'Feedback sent!', context: 'toast'})))
}, [feedFeedback, postUri, postFeedContext, _])
const onPressShowLess = React.useCallback(() => {
@@ -283,7 +283,7 @@ let PostDropdownMenuItems = ({
item: postUri,
feedContext: postFeedContext,
})
Toast.show(_(msg`Feedback sent!`))
Toast.show(_(msg({message: 'Feedback sent!', context: 'toast'})))
}, [feedFeedback, postUri, postFeedContext, _])
const onSelectChatToShareTo = React.useCallback(
@@ -314,7 +314,9 @@ let PostDropdownMenuItems = ({
: _(msg`Quote post was re-attached`),
)
} catch (e: any) {
Toast.show(_(msg`Updating quote attachment failed`))
Toast.show(
_(msg({message: 'Updating quote attachment failed', context: 'toast'})),
)
logger.error(`Failed to ${action} quote`, {safeMessage: e.message})
}
}, [_, quoteEmbed, post, toggleQuoteDetachment])
@@ -341,10 +343,12 @@ let PostDropdownMenuItems = ({
Toast.show(
isHide
? _(msg`Reply was successfully hidden`)
: _(msg`Reply visibility updated`),
: _(msg({message: 'Reply visibility updated', context: 'toast'})),
)
} catch (e: any) {
Toast.show(_(msg`Updating reply visibility failed`))
Toast.show(
_(msg({message: 'Updating reply visibility failed', context: 'toast'})),
)
logger.error(`Failed to ${action} reply`, {safeMessage: e.message})
}
}, [
@@ -368,7 +372,7 @@ let PostDropdownMenuItems = ({
const onBlockAuthor = useCallback(async () => {
try {
await queueBlock()
Toast.show(_(msg`Account blocked`))
Toast.show(_(msg({message: 'Account blocked', context: 'toast'})))
} catch (e: any) {
if (e?.name !== 'AbortError') {
logger.error('Failed to block account', {message: e})
@@ -381,7 +385,7 @@ let PostDropdownMenuItems = ({
if (postAuthor.viewer?.muted) {
try {
await queueUnmute()
Toast.show(_(msg`Account unmuted`))
Toast.show(_(msg({message: 'Account unmuted', context: 'toast'})))
} catch (e: any) {
if (e?.name !== 'AbortError') {
logger.error('Failed to unmute account', {message: e})
@@ -391,7 +395,7 @@ let PostDropdownMenuItems = ({
} else {
try {
await queueMute()
Toast.show(_(msg`Account muted`))
Toast.show(_(msg({message: 'Account muted', context: 'toast'})))
} catch (e: any) {
if (e?.name !== 'AbortError') {
logger.error('Failed to mute account', {message: e})