From 77c786581efe3b072829035ed824f901a80f161e Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 26 Aug 2025 13:20:50 +0100 Subject: [PATCH] add button to view post after sending --- src/components/Toast/Toast.tsx | 2 +- src/view/com/composer/Composer.tsx | 39 +++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/components/Toast/Toast.tsx b/src/components/Toast/Toast.tsx index 218d292c00..6b10a7ecb1 100644 --- a/src/components/Toast/Toast.tsx +++ b/src/components/Toast/Toast.tsx @@ -7,13 +7,13 @@ import { type ButtonProps, type UninheritableButtonProps, } from '#/components/Button' +import {CircleCheck_Stroke2_Corner0_Rounded as CircleCheck} from '#/components/icons/CircleCheck' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' import {CircleInfo_Stroke2_Corner0_Rounded as ErrorIcon} from '#/components/icons/CircleInfo' import {type Props as SVGIconProps} from '#/components/icons/common' import {Warning_Stroke2_Corner0_Rounded as WarningIcon} from '#/components/icons/Warning' import {type ToastType} from '#/components/Toast/types' import {Text as BaseText} from '#/components/Typography' -import {CircleCheck_Stroke2_Corner0_Rounded as CircleCheck} from '../icons/CircleCheck' type ContextType = { type: ToastType diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index c3e0526b9a..24a4cba69b 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -47,12 +47,14 @@ import { AppBskyFeedDefs, type AppBskyFeedGetPostThread, AppBskyUnspeccedDefs, + AtUri, type BskyAgent, type RichText, } from '@atproto/api' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg, plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {useNavigation} from '@react-navigation/native' import {useQueryClient} from '@tanstack/react-query' import * as apilib from '#/lib/api/index' @@ -71,6 +73,7 @@ import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' import {usePalette} from '#/lib/hooks/usePalette' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {mimeToExt} from '#/lib/media/video/util' +import {type NavigationProp} from '#/lib/routes/types' import {logEvent} from '#/lib/statsig/statsig' import {cleanError} from '#/lib/strings/errors' import {colors} from '#/lib/styles' @@ -124,12 +127,13 @@ import {Text} from '#/view/com/util/text/Text' import {UserAvatar} from '#/view/com/util/UserAvatar' import {atoms as a, native, useTheme, web} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import {CircleCheck_Stroke2_Corner0_Rounded as CircleCheckIcon} from '#/components/icons/CircleCheck' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' import {EmojiArc_Stroke2_Corner0_Rounded as EmojiSmile} from '#/components/icons/Emoji' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' import {LazyQuoteEmbed} from '#/components/Post/Embed/LazyQuoteEmbed' import * as Prompt from '#/components/Prompt' -import * as toast from '#/components/Toast' +import * as Toast from '#/components/Toast' import {Text as NewText} from '#/components/Typography' import {BottomSheetPortalProvider} from '../../../../modules/bottom-sheet' import { @@ -189,6 +193,7 @@ export const ComposePost = ({ const {closeAllDialogs} = useDialogStateControlContext() const {closeAllModals} = useModalControls() const {data: preferences} = usePreferencesQuery() + const navigation = useNavigation() const [isKeyboardVisible] = useIsKeyboardVisible({iosUseWillEvents: true}) const [isPublishing, setIsPublishing] = useState(false) @@ -522,12 +527,27 @@ export const ComposePost = ({ onPostSuccess?.(postSuccessData) } onClose() - toast.show( - thread.posts.length > 1 - ? _(msg`Your posts have been published`) - : replyTo - ? _(msg`Your reply has been published`) - : _(msg`Your post has been published`), + Toast.show( + + + + {thread.posts.length > 1 + ? _(msg`Your posts were sent`) + : replyTo + ? _(msg`Your reply was sent`) + : _(msg`Your post was sent`)} + + {postUri && ( + { + const {host: name, rkey} = new AtUri(postUri) + navigation.navigate('PostThread', {name, rkey}) + }}> + View + + )} + , {type: 'success'}, ) }, [ @@ -544,6 +564,7 @@ export const ComposePost = ({ replyTo, setLangPrefs, queryClient, + navigation, ]) // Preserves the referential identity passed to each post item. @@ -831,7 +852,7 @@ let ComposerPost = React.memo(function ComposerPost({ if (isNative) return // web only const [mimeType] = uri.slice('data:'.length).split(';') if (!SUPPORTED_MIME_TYPES.includes(mimeType as SupportedMimeTypes)) { - toast.show(_(msg`Unsupported video type: ${mimeType}`), { + Toast.show(_(msg`Unsupported video type: ${mimeType}`), { type: 'error', }) return @@ -1367,7 +1388,7 @@ function ComposerFooter({ } errors.map(error => { - toast.show(error, { + Toast.show(error, { type: 'warning', }) })