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>
This commit is contained in:
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

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

View file

@ -125,7 +125,7 @@ export function FeedSourceCardLoaded({
])
Toast.show(_(msg`Added to my feeds`))
} 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})
}
}, [_, feed, pinOnSave, addSavedFeeds, isSaved])
@ -138,7 +138,7 @@ export function FeedSourceCardLoaded({
// await item.unsave()
Toast.show(_(msg`Removed from my feeds`))
} 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})
}
}, [_, removeFeed, savedFeedConfig])

View file

@ -66,7 +66,10 @@ function LightboxFooter({imageIndex}: {imageIndex: number}) {
const saveImageToAlbumWithToasts = React.useCallback(
async (uri: string) => {
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) {
requestPermission()
} 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.`,
),
'xmark',
)
}
return
@ -83,7 +87,7 @@ function LightboxFooter({imageIndex}: {imageIndex: number}) {
await saveImageToMediaLibrary({uri})
Toast.show(_(msg`Saved to your camera roll`))
} catch (e: any) {
Toast.show(_(msg`Failed to save image: ${String(e)}`))
Toast.show(_(msg`Failed to save image: ${String(e)}`), 'xmark')
}
},
[permissionResponse, requestPermission, _],

View file

@ -77,7 +77,7 @@ export function Component({}: {}) {
const onCopy = React.useCallback(() => {
if (appPassword) {
setStringAsync(appPassword)
Toast.show(_(msg`Copied to clipboard`))
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
setWasCopied(true)
}
}, [appPassword, _])
@ -93,7 +93,7 @@ export function Component({}: {}) {
_(
msg`Please enter a name for your app password. All spaces is not allowed.`,
),
'times',
'xmark',
)
return
}
@ -101,13 +101,13 @@ export function Component({}: {}) {
if (name.length < 4) {
Toast.show(
_(msg`App Password names must be at least 4 characters long.`),
'times',
'xmark',
)
return
}
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
}
@ -116,11 +116,11 @@ export function Component({}: {}) {
if (newPassword) {
setAppPassword(newPassword.password)
} else {
Toast.show(_(msg`Failed to create app password.`), 'times')
Toast.show(_(msg`Failed to create app password.`), 'xmark')
// TODO: better error handling (?)
}
} 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})
}
}
@ -137,6 +137,7 @@ export function Component({}: {}) {
_(
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(() => {
setStringAsync(isDNSForm ? `did=${currentAccount.did}` : currentAccount.did)
Toast.show(_(msg`Copied to clipboard`))
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
}, [currentAccount, isDNSForm, _])
const onChangeHandle = React.useCallback(
(v: string) => {

View file

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

View file

@ -7,32 +7,33 @@ import {
View,
} from 'react-native'
import {AppBskyActorDefs, AppBskyGraphDefs} from '@atproto/api'
import {ScrollView, TextInput} from './util'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {Text} from '../util/text/Text'
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 {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {HITSLOP_20} from '#/lib/constants'
import {useModalControls} from '#/state/modals'
import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete'
import {
useDangerousListMembershipsQuery,
getMembership,
ListMembersip,
useDangerousListMembershipsQuery,
useListMembershipAddMutation,
useListMembershipRemoveMutation,
} 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%']
@ -200,7 +201,7 @@ function UserResult({
onChange?.('remove', profile)
}
} catch (e) {
Toast.show(cleanError(e))
Toast.show(cleanError(e), 'xmark')
} finally {
setIsProcessing(false)
}

View file

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

View file

@ -96,7 +96,7 @@ function PostThreadFollowBtnLoaded({
} catch (e: any) {
if (e?.name !== 'AbortError') {
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) {
if (e?.name !== 'AbortError') {
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(
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})
}

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.`,
),
'exclamation-circle',
)
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.`,
),
'exclamation-circle',
)
logger.error('Failed up update feeds', {message: err})
}

View file

@ -33,7 +33,7 @@ export function FollowButton({
await queueFollow()
} catch (e: any) {
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()
} catch (e: any) {
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()
} catch (e: any) {
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, _])
@ -195,7 +195,7 @@ function SuggestedFollow({
await queueUnfollow()
} catch (e: any) {
if (e?.name !== 'AbortError') {
Toast.show(_(msg`An issue occurred, please try again.`))
Toast.show(_(msg`An issue occurred, please try again.`), 'xmark')
}
}
}, [queueUnfollow, _])

View file

@ -108,7 +108,7 @@ let ProfileMenu = ({
} catch (e: any) {
if (e?.name !== 'AbortError') {
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 {
@ -119,7 +119,7 @@ let ProfileMenu = ({
} catch (e: any) {
if (e?.name !== 'AbortError') {
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) {
if (e?.name !== 'AbortError') {
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 {
@ -145,7 +145,7 @@ let ProfileMenu = ({
} catch (e: any) {
if (e?.name !== 'AbortError') {
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) {
if (e?.name !== 'AbortError') {
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])
@ -172,7 +172,7 @@ let ProfileMenu = ({
} catch (e: any) {
if (e?.name !== 'AbortError') {
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])

View file

@ -2,7 +2,7 @@
* 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 {
FontAwesomeIcon,
@ -39,7 +39,7 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({}) => {
<View style={styles.container}>
<FontAwesomeIcon
icon={activeToast.icon}
size={24}
size={20}
style={styles.icon as FontAwesomeIconStyle}
/>
<Text style={styles.text}>{activeToast.text}</Text>
@ -79,6 +79,7 @@ const styles = StyleSheet.create({
},
icon: {
color: '#fff',
flexShrink: 0,
},
text: {
color: '#fff',

View file

@ -149,7 +149,7 @@ let PostDropdownBtn = ({
},
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) {
if (e?.name !== 'AbortError') {
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])
@ -186,7 +189,7 @@ let PostDropdownBtn = ({
const str = richTextToString(richText, true)
Clipboard.setStringAsync(str)
Toast.show(_(msg`Copied to clipboard`))
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
}, [_, richText])
const onPressTranslate = React.useCallback(() => {

View file

@ -354,7 +354,7 @@ let PostCtrls = ({
onPress={e => {
e.stopPropagation()
Clipboard.setStringAsync(feedContext)
Toast.show(_(msg`Copied to clipboard`))
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
}}>
<Text
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 {faCircleDot} from '@fortawesome/free-solid-svg-icons/faCircleDot'
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 {faCommentSlash} from '@fortawesome/free-solid-svg-icons/faCommentSlash'
import {faDownload} from '@fortawesome/free-solid-svg-icons/faDownload'
@ -140,6 +141,7 @@ library.add(
faCircleExclamation,
faCirclePlay,
faCircleUser,
faClipboardCheck,
faClone,
farClone,
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.`,
),
'xmark',
)
logger.error('Failed up update feeds', {message: err})
}
@ -231,7 +232,7 @@ export function ProfileFeedScreenInner({
])
}
} 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})
}
}, [
@ -543,6 +544,7 @@ function AboutSection({
_(
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})
}

View file

@ -300,7 +300,7 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
Toast.show(_(msg`Saved to your feeds`))
}
} 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})
}
}, [
@ -319,7 +319,7 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
await removeSavedFeed(savedFeedConfig)
Toast.show(_(msg`Removed from your feeds`))
} 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})
}
}, [playHaptic, removeSavedFeed, _, savedFeedConfig])

View file

@ -234,7 +234,7 @@ function ListItem({
},
])
} 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})
}
}, [_, playHaptic, feed, updateSavedFeeds, resetSaveFeedsMutationState])
@ -260,7 +260,7 @@ function ListItem({
index: nextIndex,
})
} 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})
}
}, [feed, isPinned, overwriteSavedFeeds, currentFeeds, _])
@ -286,7 +286,7 @@ function ListItem({
index: nextIndex,
})
} 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})
}
}, [feed, isPinned, overwriteSavedFeeds, currentFeeds, _])

View file

@ -43,7 +43,7 @@ export function ExportCarDialog({
}
} catch (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 {
setLoading(false)
control.close()