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
+2 -2
View File
@@ -51,7 +51,7 @@ export function Component() {
} else {
await agent.com.atproto.server.updateEmail({email: email.trim()})
await agent.resumeSession(agent.session!)
Toast.show(_(msg`Email updated`))
Toast.show(_(msg({message: 'Email updated', context: 'toast'})))
setStage(Stages.Done)
}
} catch (e) {
@@ -80,7 +80,7 @@ export function Component() {
token: confirmationCode.trim(),
})
await agent.resumeSession(agent.session!)
Toast.show(_(msg`Email updated`))
Toast.show(_(msg({message: 'Email updated', context: 'toast'})))
setStage(Stages.Done)
} catch (e) {
setError(cleanError(String(e)))
+4 -4
View File
@@ -159,8 +159,8 @@ export function Component({
})
Toast.show(
isCurateList
? _(msg`User list updated`)
: _(msg`Moderation list updated`),
? _(msg({message: 'User list updated', context: 'toast'}))
: _(msg({message: 'Moderation list updated', context: 'toast'})),
)
onSave?.(list.uri)
} else {
@@ -173,8 +173,8 @@ export function Component({
})
Toast.show(
isCurateList
? _(msg`User list created`)
: _(msg`Moderation list created`),
? _(msg({message: 'User list created', context: 'toast'}))
: _(msg({message: 'Moderation list created', context: 'toast'})),
)
onSave?.(res.uri)
}
+1 -1
View File
@@ -121,7 +121,7 @@ export function Component({
newUserAvatar,
newUserBanner,
})
Toast.show(_(msg`Profile updated`))
Toast.show(_(msg({message: 'Profile updated', context: 'toast'})))
onUpdate?.()
closeModal()
} catch (e: any) {
+1 -1
View File
@@ -82,7 +82,7 @@ export function Component({
token: confirmationCode.trim(),
})
await agent.resumeSession(agent.session!)
Toast.show(_(msg`Email verified`))
Toast.show(_(msg({message: 'Email verified', context: 'toast'})))
closeModal()
onSuccess?.()
} catch (e) {
+6 -6
View File
@@ -104,7 +104,7 @@ let ProfileMenu = ({
if (profile.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})
@@ -114,7 +114,7 @@ let ProfileMenu = ({
} 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})
@@ -128,7 +128,7 @@ let ProfileMenu = ({
if (profile.viewer?.blocking) {
try {
await queueUnblock()
Toast.show(_(msg`Account unblocked`))
Toast.show(_(msg({message: 'Account unblocked', context: 'toast'})))
} catch (e: any) {
if (e?.name !== 'AbortError') {
logger.error('Failed to unblock account', {message: e})
@@ -138,7 +138,7 @@ let ProfileMenu = ({
} else {
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})
@@ -151,7 +151,7 @@ let ProfileMenu = ({
const onPressFollowAccount = React.useCallback(async () => {
try {
await queueFollow()
Toast.show(_(msg`Account followed`))
Toast.show(_(msg({message: 'Account followed', context: 'toast'})))
} catch (e: any) {
if (e?.name !== 'AbortError') {
logger.error('Failed to follow account', {message: e})
@@ -163,7 +163,7 @@ let ProfileMenu = ({
const onPressUnfollowAccount = React.useCallback(async () => {
try {
await queueUnfollow()
Toast.show(_(msg`Account unfollowed`))
Toast.show(_(msg({message: 'Account unfollowed', context: 'toast'})))
} catch (e: any) {
if (e?.name !== 'AbortError') {
logger.error('Failed to unfollow account', {message: e})
@@ -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})
+5 -5
View File
@@ -392,7 +392,7 @@ function Header({
const onSubscribeMute = useCallback(async () => {
try {
await listMuteMutation.mutateAsync({uri: list.uri, mute: true})
Toast.show(_(msg`List muted`))
Toast.show(_(msg({message: 'List muted', context: 'toast'})))
} catch {
Toast.show(
_(
@@ -405,7 +405,7 @@ function Header({
const onUnsubscribeMute = useCallback(async () => {
try {
await listMuteMutation.mutateAsync({uri: list.uri, mute: false})
Toast.show(_(msg`List unmuted`))
Toast.show(_(msg({message: 'List unmuted', context: 'toast'})))
} catch {
Toast.show(
_(
@@ -418,7 +418,7 @@ function Header({
const onSubscribeBlock = useCallback(async () => {
try {
await listBlockMutation.mutateAsync({uri: list.uri, block: true})
Toast.show(_(msg`List blocked`))
Toast.show(_(msg({message: 'List blocked', context: 'toast'})))
} catch {
Toast.show(
_(
@@ -431,7 +431,7 @@ function Header({
const onUnsubscribeBlock = useCallback(async () => {
try {
await listBlockMutation.mutateAsync({uri: list.uri, block: false})
Toast.show(_(msg`List unblocked`))
Toast.show(_(msg({message: 'List unblocked', context: 'toast'})))
} catch {
Toast.show(
_(
@@ -455,7 +455,7 @@ function Header({
await removeSavedFeed(savedFeedConfig)
}
Toast.show(_(msg`List deleted`))
Toast.show(_(msg({message: 'List deleted', context: 'toast'})))
if (navigation.canGoBack()) {
navigation.goBack()
} else {
+1 -1
View File
@@ -79,7 +79,7 @@ function SavedFeedsInner({
const onSaveChanges = React.useCallback(async () => {
try {
await overwriteSavedFeeds(currentFeeds)
Toast.show(_(msg`Feeds updated!`))
Toast.show(_(msg({message: 'Feeds updated!', context: 'toast'})))
navigation.navigate('Feeds')
} catch (e) {
Toast.show(_(msg`There was an issue contacting the server`), 'xmark')