Skip to content

Commit 88bbe84

Browse files
committed
use isNetworkError for failed to mute account
1 parent d0649e9 commit 88bbe84

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/components/PostControls/PostMenu/PostMenuItems.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
type NavigationProp,
2828
} from '#/lib/routes/types'
2929
import {logEvent, useGate} from '#/lib/statsig/statsig'
30+
import {isNetworkError} from '#/lib/strings/errors'
3031
import {richTextToString} from '#/lib/strings/rich-text-helpers'
3132
import {toShareUrl} from '#/lib/strings/url-helpers'
3233
import {logger} from '#/logger'
@@ -54,7 +55,6 @@ import {
5455
} from '#/state/queries/threadgate'
5556
import {useRequireAuth, useSession} from '#/state/session'
5657
import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
57-
import * as Toast from '#/view/com/util/Toast'
5858
import {useDialogControl} from '#/components/Dialog'
5959
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
6060
import {
@@ -87,6 +87,7 @@ import {
8787
useReportDialogControl,
8888
} from '#/components/moderation/ReportDialog'
8989
import * as Prompt from '#/components/Prompt'
90+
import * as Toast from '#/components/Toast'
9091
import {IS_INTERNAL} from '#/env'
9192
import * as bsky from '#/types/bsky'
9293

@@ -201,7 +202,9 @@ let PostMenuItems = ({
201202
},
202203
e => {
203204
logger.error('Failed to delete post', {message: e})
204-
Toast.show(_(msg`Failed to delete post, please try again`), 'xmark')
205+
Toast.show(_(msg`Failed to delete post, please try again`), {
206+
type: 'error',
207+
})
205208
},
206209
)
207210
}
@@ -220,10 +223,9 @@ let PostMenuItems = ({
220223
} catch (e: any) {
221224
if (e?.name !== 'AbortError') {
222225
logger.error('Failed to toggle thread mute', {message: e})
223-
Toast.show(
224-
_(msg`Failed to toggle thread mute, please try again`),
225-
'xmark',
226-
)
226+
Toast.show(_(msg`Failed to toggle thread mute, please try again`), {
227+
type: 'error',
228+
})
227229
}
228230
}
229231
}
@@ -232,7 +234,7 @@ let PostMenuItems = ({
232234
const str = richTextToString(richText, true)
233235

234236
Clipboard.setStringAsync(str)
235-
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
237+
Toast.show(_(msg`Copied to clipboard`))
236238
}
237239

238240
const onPressTranslate = () => {
@@ -394,7 +396,7 @@ let PostMenuItems = ({
394396
} catch (e: any) {
395397
if (e?.name !== 'AbortError') {
396398
logger.error('Failed to block account', {message: e})
397-
Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
399+
Toast.show(_(msg`There was an issue! ${e.toString()}`), {type: 'error'})
398400
}
399401
}
400402
}
@@ -405,19 +407,23 @@ let PostMenuItems = ({
405407
await queueUnmute()
406408
Toast.show(_(msg({message: 'Account unmuted', context: 'toast'})))
407409
} catch (e: any) {
408-
if (e?.name !== 'AbortError') {
409-
logger.error('Failed to unmute account', {message: e})
410-
Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
410+
if (!isNetworkError(e)) {
411+
logger.error('Failed to unmute account', {safeMessage: e})
412+
Toast.show(_(msg`There was an issue! ${e.toString()}`), {
413+
type: 'error',
414+
})
411415
}
412416
}
413417
} else {
414418
try {
415419
await queueMute()
416420
Toast.show(_(msg({message: 'Account muted', context: 'toast'})))
417421
} catch (e: any) {
418-
if (e?.name !== 'AbortError') {
419-
logger.error('Failed to mute account', {message: e})
420-
Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
422+
if (!isNetworkError(e)) {
423+
logger.error('Failed to mute account', {safeMessage: e})
424+
Toast.show(_(msg`There was an issue! ${e.toString()}`), {
425+
type: 'error',
426+
})
421427
}
422428
}
423429
}

0 commit comments

Comments
 (0)