Use appropriate icons for toasts (#4803)

* use appropriate icons for toasts

* use info for session expiry

* tweak size

* message -> safeMessage

---------

Co-authored-by: Samuel Newman <10959775+mozzius@users.noreply.github.com>
zio/stable
Samuel Newman 2024-07-23 15:01:04 +01:00 committed by GitHub
parent 59bafb426f
commit 27d712290a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
48 changed files with 134 additions and 95 deletions

View File

@ -95,7 +95,10 @@ function InnerApp() {
useEffect(() => { useEffect(() => {
return listenSessionDropped(() => { return listenSessionDropped(() => {
Toast.show(_(msg`Sorry! Your session expired. Please log in again.`)) Toast.show(
_(msg`Sorry! Your session expired. Please log in again.`),
'info',
)
}) })
}, [_]) }, [_])

View File

@ -77,7 +77,10 @@ function InnerApp() {
useEffect(() => { useEffect(() => {
return listenSessionDropped(() => { return listenSessionDropped(() => {
Toast.show(_(msg`Sorry! Your session expired. Please log in again.`)) Toast.show(
_(msg`Sorry! Your session expired. Please log in again.`),
'info',
)
}) })
}, [_]) }, [_])

View File

@ -264,9 +264,9 @@ function SaveButtonInner({
]) ])
} }
Toast.show(_(msg`Feeds updated!`)) Toast.show(_(msg`Feeds updated!`))
} catch (e: any) { } catch (err: any) {
logger.error(e, {context: `FeedCard: failed to update feeds`, pin}) logger.error(err, {context: `FeedCard: failed to update feeds`, pin})
Toast.show(_(msg`Failed to update feeds`)) Toast.show(_(msg`Failed to update feeds`), 'xmark')
} }
}, },
[_, pin, saveFeeds, removeFeed, uri, savedFeedConfig, type], [_, pin, saveFeeds, removeFeed, uri, savedFeedConfig, type],

View File

@ -306,9 +306,9 @@ export function FollowButtonInner({
)}`, )}`,
), ),
) )
} catch (e: any) { } catch (err: any) {
if (e?.name !== 'AbortError') { if (err?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`)) Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
} }
} }
} }
@ -326,9 +326,9 @@ export function FollowButtonInner({
)}`, )}`,
), ),
) )
} catch (e: any) { } catch (err: any) {
if (e?.name !== 'AbortError') { if (err?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`)) Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
} }
} }
} }

View File

@ -67,7 +67,10 @@ export function QrCodeDialog({
try { try {
await createAssetAsync(`file://${uri}`) await createAssetAsync(`file://${uri}`)
} catch (e: unknown) { } catch (e: unknown) {
Toast.show(_(msg`An error occurred while saving the QR code!`)) Toast.show(
_(msg`An error occurred while saving the QR code!`),
'xmark',
)
logger.error('Failed to save QR code', {error: e}) logger.error('Failed to save QR code', {error: e})
return return
} }

View File

@ -66,6 +66,7 @@ function ShareDialogInner({
if (!res) { if (!res) {
Toast.show( Toast.show(
_(msg`You must grant access to your photo library to save the image.`), _(msg`You must grant access to your photo library to save the image.`),
'xmark',
) )
return return
} }
@ -75,7 +76,7 @@ function ShareDialogInner({
Toast.show(_(msg`Image saved to your camera roll!`)) Toast.show(_(msg`Image saved to your camera roll!`))
control.close() control.close()
} catch (e: unknown) { } catch (e: unknown) {
Toast.show(_(msg`An error occurred while saving the QR code!`)) Toast.show(_(msg`An error occurred while saving the QR code!`), 'xmark')
logger.error('Failed to save QR code', {error: e}) logger.error('Failed to save QR code', {error: e})
return return
} }

View File

@ -115,6 +115,7 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) {
_( _(
msg`There was an issue. Please check your internet connection and try again.`, msg`There was an issue. Please check your internet connection and try again.`,
), ),
'xmark',
) )
logger.error('Failed to edit threadgate', {message: err}) logger.error('Failed to edit threadgate', {message: err})
} }

View File

@ -85,7 +85,7 @@ let ConvoMenu = ({
} }
}, },
onError: () => { onError: () => {
Toast.show(_(msg`Could not mute chat`)) Toast.show(_(msg`Could not mute chat`), 'xmark')
}, },
}) })

View File

@ -36,7 +36,7 @@ export function LeaveConvoPrompt({
} }
}, },
onError: () => { onError: () => {
Toast.show(_(msg`Could not leave chat`)) Toast.show(_(msg`Could not leave chat`), 'xmark')
}, },
}) })

View File

@ -54,7 +54,7 @@ export let MessageMenu = ({
) )
Clipboard.setStringAsync(str) Clipboard.setStringAsync(str)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
}, [_, message.text, message.facets]) }, [_, message.text, message.facets])
const onPressTranslateMessage = React.useCallback(() => { const onPressTranslateMessage = React.useCallback(() => {

View File

@ -57,7 +57,7 @@ function DialogInner({
const [initialized, setInitialzed] = React.useState(false) const [initialized, setInitialzed] = React.useState(false)
const {mutate: updateDeclaration} = useUpdateActorDeclaration({ const {mutate: updateDeclaration} = useUpdateActorDeclaration({
onError: () => { onError: () => {
Toast.show(_(msg`Failed to update settings`)) Toast.show(_(msg`Failed to update settings`), 'xmark')
}, },
}) })

View File

@ -2,6 +2,7 @@ import React, {useCallback} from 'react'
import {msg} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {logger} from '#/logger'
import {useGetConvoForMembers} from '#/state/queries/messages/get-convo-for-members' import {useGetConvoForMembers} from '#/state/queries/messages/get-convo-for-members'
import {logEvent} from 'lib/statsig/statsig' import {logEvent} from 'lib/statsig/statsig'
import {FAB} from '#/view/com/util/fab/FAB' import {FAB} from '#/view/com/util/fab/FAB'
@ -31,7 +32,8 @@ export function NewChat({
logEvent('chat:open', {logContext: 'NewChatDialog'}) logEvent('chat:open', {logContext: 'NewChatDialog'})
}, },
onError: error => { onError: error => {
Toast.show(error.message) logger.error('Failed to create chat', {safeMessage: error})
Toast.show(_(msg`An issue occurred starting the chat`), 'xmark')
}, },
}) })

View File

@ -2,6 +2,7 @@ import React, {useCallback} from 'react'
import {msg} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {logger} from '#/logger'
import {useGetConvoForMembers} from '#/state/queries/messages/get-convo-for-members' import {useGetConvoForMembers} from '#/state/queries/messages/get-convo-for-members'
import {logEvent} from 'lib/statsig/statsig' import {logEvent} from 'lib/statsig/statsig'
import * as Toast from '#/view/com/util/Toast' import * as Toast from '#/view/com/util/Toast'
@ -43,7 +44,11 @@ function SendViaChatDialogInner({
logEvent('chat:open', {logContext: 'SendViaChatDialog'}) logEvent('chat:open', {logContext: 'SendViaChatDialog'})
}, },
onError: error => { onError: error => {
Toast.show(error.message) logger.error('Failed to share post to chat', {message: error})
Toast.show(
_(msg`An issue occurred while trying to open the chat`),
'xmark',
)
}, },
}) })

View File

@ -32,7 +32,7 @@ export function useFollowMethods({
} catch (e: any) { } catch (e: any) {
logger.error(`useFollowMethods: failed to follow`, {message: String(e)}) logger.error(`useFollowMethods: failed to follow`, {message: String(e)})
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`)) Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
} }
} }
}) })
@ -47,7 +47,7 @@ export function useFollowMethods({
message: String(e), message: String(e),
}) })
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`)) Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
} }
} }
}) })

View File

@ -241,7 +241,7 @@ function AppealForm({
}, },
onError: err => { onError: err => {
logger.error('Failed to submit label appeal', {message: err}) logger.error('Failed to submit label appeal', {message: err})
Toast.show(_(msg`Failed to submit appeal, please try again.`)) Toast.show(_(msg`Failed to submit appeal, please try again.`), 'xmark')
}, },
onSuccess: () => { onSuccess: () => {
control.close() control.close()

View File

@ -17,14 +17,14 @@ export async function openPicker(opts?: ImagePickerOptions) {
}) })
if (response.assets && response.assets.length > 4) { if (response.assets && response.assets.length > 4) {
Toast.show('You may only select up to 4 images') Toast.show('You may only select up to 4 images', 'exclamation-circle')
} }
return (response.assets ?? []) return (response.assets ?? [])
.slice(0, 4) .slice(0, 4)
.filter(asset => { .filter(asset => {
if (asset.mimeType?.startsWith('image/')) return true if (asset.mimeType?.startsWith('image/')) return true
Toast.show('Only image files are supported') Toast.show('Only image files are supported', 'exclamation-circle')
return false return false
}) })
.map(image => ({ .map(image => ({

View File

@ -20,6 +20,6 @@ export async function shareUrl(url: string) {
// React Native Share is not supported by web. Web Share API // React Native Share is not supported by web. Web Share API
// has increasing but not full support, so default to clipboard // has increasing but not full support, so default to clipboard
setStringAsync(url) setStringAsync(url)
Toast.show('Copied to clipboard') Toast.show('Copied to clipboard', 'clipboard-check')
} }
} }

View File

@ -84,7 +84,7 @@ function DialogInner() {
}, },
onError: err => { onError: err => {
logger.error('Failed to submit chat appeal', {message: err}) logger.error('Failed to submit chat appeal', {message: err})
Toast.show(_(msg`Failed to submit appeal, please try again.`)) Toast.show(_(msg`Failed to submit appeal, please try again.`), 'xmark')
}, },
onSuccess: () => { onSuccess: () => {
control.close() control.close()

View File

@ -67,7 +67,7 @@ export function MessageInput({
return return
} }
if (new Graphemer().countGraphemes(message) > MAX_DM_GRAPHEME_LENGTH) { if (new Graphemer().countGraphemes(message) > MAX_DM_GRAPHEME_LENGTH) {
Toast.show(_(msg`Message is too long`)) Toast.show(_(msg`Message is too long`), 'xmark')
return return
} }
clearDraft() clearDraft()

View File

@ -46,7 +46,7 @@ export function MessageInput({
return return
} }
if (new Graphemer().countGraphemes(message) > MAX_DM_GRAPHEME_LENGTH) { if (new Graphemer().countGraphemes(message) > MAX_DM_GRAPHEME_LENGTH) {
Toast.show(_(msg`Message is too long`)) Toast.show(_(msg`Message is too long`), 'xmark')
return return
} }
clearDraft() clearDraft()

View File

@ -32,7 +32,7 @@ export function MessagesSettingsScreen({}: Props) {
const {mutate: updateDeclaration} = useUpdateActorDeclaration({ const {mutate: updateDeclaration} = useUpdateActorDeclaration({
onError: () => { onError: () => {
Toast.show(_(msg`Failed to update settings`)) Toast.show(_(msg`Failed to update settings`), 'xmark')
}, },
}) })

View File

@ -116,6 +116,7 @@ let ProfileHeaderLabeler = ({
_( _(
msg`There was an an issue contacting the server, please check your internet connection and try again.`, msg`There was an an issue contacting the server, please check your internet connection and try again.`,
), ),
'xmark',
) )
logger.error(`Failed to toggle labeler like`, {message: e.message}) logger.error(`Failed to toggle labeler like`, {message: e.message})
} }

View File

@ -104,7 +104,7 @@ let ProfileHeaderStandard = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to follow', {message: String(e)}) logger.error('Failed to follow', {message: String(e)})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
}) })
@ -126,7 +126,7 @@ let ProfileHeaderStandard = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to unfollow', {message: String(e)}) logger.error('Failed to unfollow', {message: String(e)})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
}) })
@ -140,7 +140,7 @@ let ProfileHeaderStandard = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to unblock account', {message: e}) logger.error('Failed to unblock account', {message: e})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
}, [_, queueUnblock, track]) }, [_, queueUnblock, track])

View File

@ -359,7 +359,7 @@ function Header({
captureAction(ProgressGuideAction.Follow, dids.length) captureAction(ProgressGuideAction.Follow, dids.length)
Toast.show(_(msg`All accounts have been followed!`)) Toast.show(_(msg`All accounts have been followed!`))
} catch (e) { } catch (e) {
Toast.show(_(msg`An error occurred while trying to follow all`)) Toast.show(_(msg`An error occurred while trying to follow all`), 'xmark')
} finally { } finally {
setIsProcessing(false) setIsProcessing(false)
} }
@ -672,7 +672,7 @@ function InvalidStarterPack({rkey}: {rkey: string}) {
onError: e => { onError: e => {
setIsProcessing(false) setIsProcessing(false)
logger.error('Failed to delete invalid starter pack', {safeMessage: e}) logger.error('Failed to delete invalid starter pack', {safeMessage: e})
Toast.show(_(msg`Failed to delete starter pack`)) Toast.show(_(msg`Failed to delete starter pack`), 'xmark')
}, },
}) })

View File

@ -74,7 +74,10 @@ function reducer(state: State, action: Action): State {
break break
case 'AddProfile': case 'AddProfile':
if (state.profiles.length >= 51) { if (state.profiles.length >= 51) {
Toast.show(msg`You may only add up to 50 profiles`.message ?? '') Toast.show(
msg`You may only add up to 50 profiles`.message ?? '',
'info',
)
} else { } else {
updatedState = {...state, profiles: [...state.profiles, action.profile]} updatedState = {...state, profiles: [...state.profiles, action.profile]}
} }
@ -89,7 +92,7 @@ function reducer(state: State, action: Action): State {
break break
case 'AddFeed': case 'AddFeed':
if (state.feeds.length >= 50) { if (state.feeds.length >= 50) {
Toast.show(msg`You may only add up to 50 feeds`.message ?? '') Toast.show(msg`You may only add up to 50 feeds`.message ?? '', 'info')
} else { } else {
updatedState = {...state, feeds: [...state.feeds, action.feed]} updatedState = {...state, feeds: [...state.feeds, action.feed]}
} }

View File

@ -227,7 +227,7 @@ function WizardInner({
onError: e => { onError: e => {
logger.error('Failed to create starter pack', {safeMessage: e}) logger.error('Failed to create starter pack', {safeMessage: e})
dispatch({type: 'SetProcessing', processing: false}) dispatch({type: 'SetProcessing', processing: false})
Toast.show(_(msg`Failed to create starter pack`)) Toast.show(_(msg`Failed to create starter pack`), 'xmark')
}, },
}) })
const {mutate: editStarterPack} = useEditStarterPackMutation({ const {mutate: editStarterPack} = useEditStarterPackMutation({
@ -235,7 +235,7 @@ function WizardInner({
onError: e => { onError: e => {
logger.error('Failed to edit starter pack', {safeMessage: e}) logger.error('Failed to edit starter pack', {safeMessage: e})
dispatch({type: 'SetProcessing', processing: false}) dispatch({type: 'SetProcessing', processing: false})
Toast.show(_(msg`Failed to create starter pack`)) Toast.show(_(msg`Failed to create starter pack`), 'xmark')
}, },
}) })

View File

@ -24,7 +24,7 @@ export function useVideoState({setError}: {setError: (error: string) => void}) {
onError: (e: any) => { onError: (e: any) => {
// Don't log these errors in sentry, just let the user know // Don't log these errors in sentry, just let the user know
if (e instanceof VideoTooLargeError) { if (e instanceof VideoTooLargeError) {
Toast.show(_(msg`Videos cannot be larger than 100MB`)) Toast.show(_(msg`Videos cannot be larger than 100MB`), 'xmark')
return return
} }
logger.error('Failed to compress video', {safeError: e}) logger.error('Failed to compress video', {safeError: e})

View File

@ -125,7 +125,7 @@ export function FeedSourceCardLoaded({
]) ])
Toast.show(_(msg`Added to my feeds`)) Toast.show(_(msg`Added to my feeds`))
} catch (e) { } catch (e) {
Toast.show(_(msg`There was an issue contacting your server`)) Toast.show(_(msg`There was an issue contacting your server`), 'xmark')
logger.error('Failed to save feed', {message: e}) logger.error('Failed to save feed', {message: e})
} }
}, [_, feed, pinOnSave, addSavedFeeds, isSaved]) }, [_, feed, pinOnSave, addSavedFeeds, isSaved])
@ -138,7 +138,7 @@ export function FeedSourceCardLoaded({
// await item.unsave() // await item.unsave()
Toast.show(_(msg`Removed from my feeds`)) Toast.show(_(msg`Removed from my feeds`))
} catch (e) { } catch (e) {
Toast.show(_(msg`There was an issue contacting your server`)) Toast.show(_(msg`There was an issue contacting your server`), 'xmark')
logger.error('Failed to unsave feed', {message: e}) logger.error('Failed to unsave feed', {message: e})
} }
}, [_, removeFeed, savedFeedConfig]) }, [_, removeFeed, savedFeedConfig])

View File

@ -66,7 +66,10 @@ function LightboxFooter({imageIndex}: {imageIndex: number}) {
const saveImageToAlbumWithToasts = React.useCallback( const saveImageToAlbumWithToasts = React.useCallback(
async (uri: string) => { async (uri: string) => {
if (!permissionResponse || permissionResponse.granted === false) { if (!permissionResponse || permissionResponse.granted === false) {
Toast.show(_(msg`Permission to access camera roll is required.`)) Toast.show(
_(msg`Permission to access camera roll is required.`),
'info',
)
if (permissionResponse?.canAskAgain) { if (permissionResponse?.canAskAgain) {
requestPermission() requestPermission()
} else { } else {
@ -74,6 +77,7 @@ function LightboxFooter({imageIndex}: {imageIndex: number}) {
_( _(
msg`Permission to access camera roll was denied. Please enable it in your system settings.`, msg`Permission to access camera roll was denied. Please enable it in your system settings.`,
), ),
'xmark',
) )
} }
return return
@ -83,7 +87,7 @@ function LightboxFooter({imageIndex}: {imageIndex: number}) {
await saveImageToMediaLibrary({uri}) await saveImageToMediaLibrary({uri})
Toast.show(_(msg`Saved to your camera roll`)) Toast.show(_(msg`Saved to your camera roll`))
} catch (e: any) { } catch (e: any) {
Toast.show(_(msg`Failed to save image: ${String(e)}`)) Toast.show(_(msg`Failed to save image: ${String(e)}`), 'xmark')
} }
}, },
[permissionResponse, requestPermission, _], [permissionResponse, requestPermission, _],

View File

@ -77,7 +77,7 @@ export function Component({}: {}) {
const onCopy = React.useCallback(() => { const onCopy = React.useCallback(() => {
if (appPassword) { if (appPassword) {
setStringAsync(appPassword) setStringAsync(appPassword)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
setWasCopied(true) setWasCopied(true)
} }
}, [appPassword, _]) }, [appPassword, _])
@ -93,7 +93,7 @@ export function Component({}: {}) {
_( _(
msg`Please enter a name for your app password. All spaces is not allowed.`, msg`Please enter a name for your app password. All spaces is not allowed.`,
), ),
'times', 'xmark',
) )
return return
} }
@ -101,13 +101,13 @@ export function Component({}: {}) {
if (name.length < 4) { if (name.length < 4) {
Toast.show( Toast.show(
_(msg`App Password names must be at least 4 characters long.`), _(msg`App Password names must be at least 4 characters long.`),
'times', 'xmark',
) )
return return
} }
if (passwords?.find(p => p.name === name)) { if (passwords?.find(p => p.name === name)) {
Toast.show(_(msg`This name is already in use`), 'times') Toast.show(_(msg`This name is already in use`), 'xmark')
return return
} }
@ -116,11 +116,11 @@ export function Component({}: {}) {
if (newPassword) { if (newPassword) {
setAppPassword(newPassword.password) setAppPassword(newPassword.password)
} else { } else {
Toast.show(_(msg`Failed to create app password.`), 'times') Toast.show(_(msg`Failed to create app password.`), 'xmark')
// TODO: better error handling (?) // TODO: better error handling (?)
} }
} catch (e) { } catch (e) {
Toast.show(_(msg`Failed to create app password.`), 'times') Toast.show(_(msg`Failed to create app password.`), 'xmark')
logger.error('Failed to create app password', {message: e}) logger.error('Failed to create app password', {message: e})
} }
} }
@ -137,6 +137,7 @@ export function Component({}: {}) {
_( _(
msg`App Password names can only contain letters, numbers, spaces, dashes, and underscores.`, msg`App Password names can only contain letters, numbers, spaces, dashes, and underscores.`,
), ),
'xmark',
) )
} }
} }

View File

@ -317,7 +317,7 @@ function CustomHandleForm({
// = // =
const onPressCopy = React.useCallback(() => { const onPressCopy = React.useCallback(() => {
setStringAsync(isDNSForm ? `did=${currentAccount.did}` : currentAccount.did) setStringAsync(isDNSForm ? `did=${currentAccount.did}` : currentAccount.did)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
}, [currentAccount, isDNSForm, _]) }, [currentAccount, isDNSForm, _])
const onChangeHandle = React.useCallback( const onChangeHandle = React.useCallback(
(v: string) => { (v: string) => {

View File

@ -150,7 +150,7 @@ function InviteCode({
const onPress = React.useCallback(() => { const onPress = React.useCallback(() => {
setStringAsync(invite.code) setStringAsync(invite.code)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
setInviteCopied(invite.code) setInviteCopied(invite.code)
}, [setInviteCopied, invite, _]) }, [setInviteCopied, invite, _])

View File

@ -7,32 +7,33 @@ import {
View, View,
} from 'react-native' } from 'react-native'
import {AppBskyActorDefs, AppBskyGraphDefs} from '@atproto/api' import {AppBskyActorDefs, AppBskyGraphDefs} from '@atproto/api'
import {ScrollView, TextInput} from './util'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {Text} from '../util/text/Text' import {msg, Trans} from '@lingui/macro'
import {Button} from '../util/forms/Button'
import {UserAvatar} from '../util/UserAvatar'
import * as Toast from '../util/Toast'
import {s, colors} from 'lib/styles'
import {usePalette} from 'lib/hooks/usePalette'
import {isWeb} from 'platform/detection'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {useIsKeyboardVisible} from 'lib/hooks/useIsKeyboardVisible'
import {cleanError} from 'lib/strings/errors'
import {sanitizeDisplayName} from 'lib/strings/display-names'
import {sanitizeHandle} from 'lib/strings/handles'
import {HITSLOP_20} from '#/lib/constants'
import {Trans, msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {HITSLOP_20} from '#/lib/constants'
import {useModalControls} from '#/state/modals' import {useModalControls} from '#/state/modals'
import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete'
import { import {
useDangerousListMembershipsQuery,
getMembership, getMembership,
ListMembersip, ListMembersip,
useDangerousListMembershipsQuery,
useListMembershipAddMutation, useListMembershipAddMutation,
useListMembershipRemoveMutation, useListMembershipRemoveMutation,
} from '#/state/queries/list-memberships' } from '#/state/queries/list-memberships'
import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete' import {useIsKeyboardVisible} from 'lib/hooks/useIsKeyboardVisible'
import {usePalette} from 'lib/hooks/usePalette'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {sanitizeDisplayName} from 'lib/strings/display-names'
import {cleanError} from 'lib/strings/errors'
import {sanitizeHandle} from 'lib/strings/handles'
import {colors, s} from 'lib/styles'
import {isWeb} from 'platform/detection'
import {Button} from '../util/forms/Button'
import {Text} from '../util/text/Text'
import * as Toast from '../util/Toast'
import {UserAvatar} from '../util/UserAvatar'
import {ScrollView, TextInput} from './util'
export const snapPoints = ['90%'] export const snapPoints = ['90%']
@ -200,7 +201,7 @@ function UserResult({
onChange?.('remove', profile) onChange?.('remove', profile)
} }
} catch (e) { } catch (e) {
Toast.show(cleanError(e)) Toast.show(cleanError(e), 'xmark')
} finally { } finally {
setIsProcessing(false) setIsProcessing(false)
} }

View File

@ -166,7 +166,7 @@ function ListItem({
onRemove?.(list.uri) onRemove?.(list.uri)
} }
} catch (e) { } catch (e) {
Toast.show(cleanError(e)) Toast.show(cleanError(e), 'xmark')
} finally { } finally {
setIsProcessing(false) setIsProcessing(false)
} }

View File

@ -96,7 +96,7 @@ function PostThreadFollowBtnLoaded({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to follow', {message: String(e)}) logger.error('Failed to follow', {message: String(e)})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
}) })
@ -108,7 +108,7 @@ function PostThreadFollowBtnLoaded({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to unfollow', {message: String(e)}) logger.error('Failed to unfollow', {message: String(e)})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
}) })

View File

@ -144,6 +144,7 @@ function FeedgenErrorMessage({
_l( _l(
msgLingui`There was an an issue removing this feed. Please check your internet connection and try again.`, msgLingui`There was an an issue removing this feed. Please check your internet connection and try again.`,
), ),
'exclamation-circle',
) )
logger.error('Failed to remove feed', {message: err}) logger.error('Failed to remove feed', {message: err})
} }

View File

@ -51,6 +51,7 @@ export function FeedShutdownMsg({feedUri}: {feedUri: string}) {
_( _(
msg`There was an an issue updating your feeds, please check your internet connection and try again.`, msg`There was an an issue updating your feeds, please check your internet connection and try again.`,
), ),
'exclamation-circle',
) )
logger.error('Failed up update feeds', {message: err}) logger.error('Failed up update feeds', {message: err})
} }
@ -69,6 +70,7 @@ export function FeedShutdownMsg({feedUri}: {feedUri: string}) {
_( _(
msg`There was an an issue updating your feeds, please check your internet connection and try again.`, msg`There was an an issue updating your feeds, please check your internet connection and try again.`,
), ),
'exclamation-circle',
) )
logger.error('Failed up update feeds', {message: err}) logger.error('Failed up update feeds', {message: err})
} }

View File

@ -33,7 +33,7 @@ export function FollowButton({
await queueFollow() await queueFollow()
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`)) Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
} }
} }
} }
@ -43,7 +43,7 @@ export function FollowButton({
await queueUnfollow() await queueUnfollow()
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`)) Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
} }
} }
} }

View File

@ -185,7 +185,7 @@ function SuggestedFollow({
await queueFollow() await queueFollow()
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`)) Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
} }
} }
}, [queueFollow, track, _]) }, [queueFollow, track, _])
@ -195,7 +195,7 @@ function SuggestedFollow({
await queueUnfollow() await queueUnfollow()
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`)) Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
} }
} }
}, [queueUnfollow, _]) }, [queueUnfollow, _])

View File

@ -108,7 +108,7 @@ let ProfileMenu = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to unmute account', {message: e}) logger.error('Failed to unmute account', {message: e})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
} else { } else {
@ -119,7 +119,7 @@ let ProfileMenu = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to mute account', {message: e}) logger.error('Failed to mute account', {message: e})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
} }
@ -134,7 +134,7 @@ let ProfileMenu = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to unblock account', {message: e}) logger.error('Failed to unblock account', {message: e})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
} else { } else {
@ -145,7 +145,7 @@ let ProfileMenu = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to block account', {message: e}) logger.error('Failed to block account', {message: e})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
} }
@ -159,7 +159,7 @@ let ProfileMenu = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to follow account', {message: e}) logger.error('Failed to follow account', {message: e})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
}, [_, queueFollow, track]) }, [_, queueFollow, track])
@ -172,7 +172,7 @@ let ProfileMenu = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to unfollow account', {message: e}) logger.error('Failed to unfollow account', {message: e})
Toast.show(_(msg`There was an issue! ${e.toString()}`)) Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
} }
} }
}, [_, queueUnfollow, track]) }, [_, queueUnfollow, track])

View File

@ -2,7 +2,7 @@
* Note: the dataSet properties are used to leverage custom CSS in public/index.html * Note: the dataSet properties are used to leverage custom CSS in public/index.html
*/ */
import React, {useState, useEffect} from 'react' import React, {useEffect, useState} from 'react'
import {StyleSheet, Text, View} from 'react-native' import {StyleSheet, Text, View} from 'react-native'
import { import {
FontAwesomeIcon, FontAwesomeIcon,
@ -39,7 +39,7 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({}) => {
<View style={styles.container}> <View style={styles.container}>
<FontAwesomeIcon <FontAwesomeIcon
icon={activeToast.icon} icon={activeToast.icon}
size={24} size={20}
style={styles.icon as FontAwesomeIconStyle} style={styles.icon as FontAwesomeIconStyle}
/> />
<Text style={styles.text}>{activeToast.text}</Text> <Text style={styles.text}>{activeToast.text}</Text>
@ -79,6 +79,7 @@ const styles = StyleSheet.create({
}, },
icon: { icon: {
color: '#fff', color: '#fff',
flexShrink: 0,
}, },
text: { text: {
color: '#fff', color: '#fff',

View File

@ -149,7 +149,7 @@ let PostDropdownBtn = ({
}, },
e => { e => {
logger.error('Failed to delete post', {message: e}) logger.error('Failed to delete post', {message: e})
Toast.show(_(msg`Failed to delete post, please try again`)) Toast.show(_(msg`Failed to delete post, please try again`), 'xmark')
}, },
) )
}, [ }, [
@ -177,7 +177,10 @@ let PostDropdownBtn = ({
} catch (e: any) { } catch (e: any) {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
logger.error('Failed to toggle thread mute', {message: e}) logger.error('Failed to toggle thread mute', {message: e})
Toast.show(_(msg`Failed to toggle thread mute, please try again`)) Toast.show(
_(msg`Failed to toggle thread mute, please try again`),
'xmark',
)
} }
} }
}, [isThreadMuted, unmuteThread, _, muteThread]) }, [isThreadMuted, unmuteThread, _, muteThread])
@ -186,7 +189,7 @@ let PostDropdownBtn = ({
const str = richTextToString(richText, true) const str = richTextToString(richText, true)
Clipboard.setStringAsync(str) Clipboard.setStringAsync(str)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
}, [_, richText]) }, [_, richText])
const onPressTranslate = React.useCallback(() => { const onPressTranslate = React.useCallback(() => {

View File

@ -354,7 +354,7 @@ let PostCtrls = ({
onPress={e => { onPress={e => {
e.stopPropagation() e.stopPropagation()
Clipboard.setStringAsync(feedContext) Clipboard.setStringAsync(feedContext)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
}}> }}>
<Text <Text
style={{ style={{

View File

@ -51,6 +51,7 @@ import {faChevronRight} from '@fortawesome/free-solid-svg-icons/faChevronRight'
import {faCircleCheck} from '@fortawesome/free-solid-svg-icons/faCircleCheck' import {faCircleCheck} from '@fortawesome/free-solid-svg-icons/faCircleCheck'
import {faCircleDot} from '@fortawesome/free-solid-svg-icons/faCircleDot' import {faCircleDot} from '@fortawesome/free-solid-svg-icons/faCircleDot'
import {faCircleExclamation} from '@fortawesome/free-solid-svg-icons/faCircleExclamation' import {faCircleExclamation} from '@fortawesome/free-solid-svg-icons/faCircleExclamation'
import {faClipboardCheck} from '@fortawesome/free-solid-svg-icons/faClipboardCheck'
import {faClone} from '@fortawesome/free-solid-svg-icons/faClone' import {faClone} from '@fortawesome/free-solid-svg-icons/faClone'
import {faCommentSlash} from '@fortawesome/free-solid-svg-icons/faCommentSlash' import {faCommentSlash} from '@fortawesome/free-solid-svg-icons/faCommentSlash'
import {faDownload} from '@fortawesome/free-solid-svg-icons/faDownload' import {faDownload} from '@fortawesome/free-solid-svg-icons/faDownload'
@ -140,6 +141,7 @@ library.add(
faCircleExclamation, faCircleExclamation,
faCirclePlay, faCirclePlay,
faCircleUser, faCircleUser,
faClipboardCheck,
faClone, faClone,
farClone, farClone,
faComment, faComment,

View File

@ -205,6 +205,7 @@ export function ProfileFeedScreenInner({
_( _(
msg`There was an an issue updating your feeds, please check your internet connection and try again.`, msg`There was an an issue updating your feeds, please check your internet connection and try again.`,
), ),
'xmark',
) )
logger.error('Failed up update feeds', {message: err}) logger.error('Failed up update feeds', {message: err})
} }
@ -231,7 +232,7 @@ export function ProfileFeedScreenInner({
]) ])
} }
} catch (e) { } catch (e) {
Toast.show(_(msg`There was an issue contacting the server`)) Toast.show(_(msg`There was an issue contacting the server`), 'xmark')
logger.error('Failed to toggle pinned feed', {message: e}) logger.error('Failed to toggle pinned feed', {message: e})
} }
}, [ }, [
@ -543,6 +544,7 @@ function AboutSection({
_( _(
msg`There was an an issue contacting the server, please check your internet connection and try again.`, msg`There was an an issue contacting the server, please check your internet connection and try again.`,
), ),
'xmark',
) )
logger.error('Failed up toggle like', {message: err}) logger.error('Failed up toggle like', {message: err})
} }

View File

@ -300,7 +300,7 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
Toast.show(_(msg`Saved to your feeds`)) Toast.show(_(msg`Saved to your feeds`))
} }
} catch (e) { } catch (e) {
Toast.show(_(msg`There was an issue contacting the server`)) Toast.show(_(msg`There was an issue contacting the server`), 'xmark')
logger.error('Failed to toggle pinned feed', {message: e}) logger.error('Failed to toggle pinned feed', {message: e})
} }
}, [ }, [
@ -319,7 +319,7 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
await removeSavedFeed(savedFeedConfig) await removeSavedFeed(savedFeedConfig)
Toast.show(_(msg`Removed from your feeds`)) Toast.show(_(msg`Removed from your feeds`))
} catch (e) { } catch (e) {
Toast.show(_(msg`There was an issue contacting the server`)) Toast.show(_(msg`There was an issue contacting the server`), 'xmark')
logger.error('Failed to remove pinned list', {message: e}) logger.error('Failed to remove pinned list', {message: e})
} }
}, [playHaptic, removeSavedFeed, _, savedFeedConfig]) }, [playHaptic, removeSavedFeed, _, savedFeedConfig])

View File

@ -234,7 +234,7 @@ function ListItem({
}, },
]) ])
} catch (e) { } catch (e) {
Toast.show(_(msg`There was an issue contacting the server`)) Toast.show(_(msg`There was an issue contacting the server`), 'xmark')
logger.error('Failed to toggle pinned feed', {message: e}) logger.error('Failed to toggle pinned feed', {message: e})
} }
}, [_, playHaptic, feed, updateSavedFeeds, resetSaveFeedsMutationState]) }, [_, playHaptic, feed, updateSavedFeeds, resetSaveFeedsMutationState])
@ -260,7 +260,7 @@ function ListItem({
index: nextIndex, index: nextIndex,
}) })
} catch (e) { } catch (e) {
Toast.show(_(msg`There was an issue contacting the server`)) Toast.show(_(msg`There was an issue contacting the server`), 'xmark')
logger.error('Failed to set pinned feed order', {message: e}) logger.error('Failed to set pinned feed order', {message: e})
} }
}, [feed, isPinned, overwriteSavedFeeds, currentFeeds, _]) }, [feed, isPinned, overwriteSavedFeeds, currentFeeds, _])
@ -286,7 +286,7 @@ function ListItem({
index: nextIndex, index: nextIndex,
}) })
} catch (e) { } catch (e) {
Toast.show(_(msg`There was an issue contacting the server`)) Toast.show(_(msg`There was an issue contacting the server`), 'xmark')
logger.error('Failed to set pinned feed order', {message: e}) logger.error('Failed to set pinned feed order', {message: e})
} }
}, [feed, isPinned, overwriteSavedFeeds, currentFeeds, _]) }, [feed, isPinned, overwriteSavedFeeds, currentFeeds, _])

View File

@ -43,7 +43,7 @@ export function ExportCarDialog({
} }
} catch (e) { } catch (e) {
logger.error('Error occurred while downloading CAR file', {message: e}) logger.error('Error occurred while downloading CAR file', {message: e})
Toast.show(_(msg`Error occurred while saving file`)) Toast.show(_(msg`Error occurred while saving file`), 'xmark')
} finally { } finally {
setLoading(false) setLoading(false)
control.close() control.close()