Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Navigate back from a deleted post's route (#2948)

authored by

dan and committed by
GitHub
43206d9f f88b1652

+30 -1
+30 -1
src/view/com/util/forms/PostDropdownBtn.tsx
··· 2 2 import {StyleProp, View, ViewStyle} from 'react-native' 3 3 import Clipboard from '@react-native-clipboard/clipboard' 4 4 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' 5 + import {useNavigation} from '@react-navigation/native' 5 6 import { 6 7 AppBskyActorDefs, 7 8 AppBskyFeedPost, ··· 19 20 import {EventStopper} from '../EventStopper' 20 21 import {useModalControls} from '#/state/modals' 21 22 import {makeProfileLink} from '#/lib/routes/links' 23 + import {CommonNavigatorParams} from '#/lib/routes/types' 24 + import {getCurrentRoute} from 'lib/routes/helpers' 22 25 import {getTranslatorLink} from '#/locale/helpers' 23 26 import {usePostDeleteMutation} from '#/state/queries/post' 24 27 import {useMutedThreads, useToggleThreadMute} from '#/state/muted-threads' ··· 63 66 const hiddenPosts = useHiddenPosts() 64 67 const {hidePost} = useHiddenPostsApi() 65 68 const openLink = useOpenLink() 69 + const navigation = useNavigation() 66 70 67 71 const rootUri = record.reply?.root?.uri || postUri 68 72 const isThreadMuted = mutedThreads.includes(rootUri) ··· 82 86 postDeleteMutation.mutateAsync({uri: postUri}).then( 83 87 () => { 84 88 Toast.show(_(msg`Post deleted`)) 89 + 90 + const route = getCurrentRoute(navigation.getState()) 91 + if (route.name === 'PostThread') { 92 + const params = route.params as CommonNavigatorParams['PostThread'] 93 + if ( 94 + currentAccount && 95 + isAuthor && 96 + (params.name === currentAccount.handle || 97 + params.name === currentAccount.did) 98 + ) { 99 + const currentHref = makeProfileLink(postAuthor, 'post', params.rkey) 100 + if (currentHref === href && navigation.canGoBack()) { 101 + navigation.goBack() 102 + } 103 + } 104 + } 85 105 }, 86 106 e => { 87 107 logger.error('Failed to delete post', {message: e}) 88 108 Toast.show(_(msg`Failed to delete post, please try again`)) 89 109 }, 90 110 ) 91 - }, [postUri, postDeleteMutation, _]) 111 + }, [ 112 + navigation, 113 + postUri, 114 + postDeleteMutation, 115 + postAuthor, 116 + currentAccount, 117 + isAuthor, 118 + href, 119 + _, 120 + ]) 92 121 93 122 const onToggleThreadMute = React.useCallback(() => { 94 123 try {