Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Some me model cleanup (#1928)

* Replace me model in post dropdown btn

* Replace delete account logic

* Replace me model in bottom bar web

* Replace me model in bottom bar

* Replace me model in reply prompt

* Better fallback

* Fix reference

* Fix bad ref in bottom bar

authored by

Eric Bailey and committed by
GitHub
310a7eac a652b52b

+41 -22
+5 -3
src/view/com/composer/Prompt.tsx
··· 3 3 import {UserAvatar} from '../util/UserAvatar' 4 4 import {Text} from '../util/text/Text' 5 5 import {usePalette} from 'lib/hooks/usePalette' 6 - import {useStores} from 'state/index' 7 6 import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' 8 7 import {Trans, msg} from '@lingui/macro' 9 8 import {useLingui} from '@lingui/react' 9 + import {useSession} from '#/state/session' 10 + import {useProfileQuery} from '#/state/queries/profile' 10 11 11 12 export function ComposePrompt({onPressCompose}: {onPressCompose: () => void}) { 12 - const store = useStores() 13 + const {currentAccount} = useSession() 14 + const {data: profile} = useProfileQuery({did: currentAccount?.did}) 13 15 const pal = usePalette('default') 14 16 const {_} = useLingui() 15 17 const {isDesktop} = useWebMediaQueries() ··· 21 23 accessibilityRole="button" 22 24 accessibilityLabel={_(msg`Compose reply`)} 23 25 accessibilityHint="Opens composer"> 24 - <UserAvatar avatar={store.me.avatar} size={38} /> 26 + <UserAvatar avatar={profile?.avatar} size={38} /> 25 27 <Text 26 28 type="xl" 27 29 style={[
+13 -7
src/view/com/modals/DeleteAccount.tsx
··· 9 9 import LinearGradient from 'react-native-linear-gradient' 10 10 import * as Toast from '../util/Toast' 11 11 import {Text} from '../util/text/Text' 12 - import {useStores} from 'state/index' 13 12 import {s, colors, gradients} from 'lib/styles' 14 13 import {usePalette} from 'lib/hooks/usePalette' 15 14 import {useTheme} from 'lib/ThemeContext' ··· 20 19 import {Trans, msg} from '@lingui/macro' 21 20 import {useLingui} from '@lingui/react' 22 21 import {useModalControls} from '#/state/modals' 22 + import {useSession, useSessionApi} from '#/state/session' 23 23 24 24 export const snapPoints = ['60%'] 25 25 26 26 export function Component({}: {}) { 27 27 const pal = usePalette('default') 28 28 const theme = useTheme() 29 - const store = useStores() 29 + const {agent, currentAccount} = useSession() 30 + const {clearCurrentAccount, removeAccount} = useSessionApi() 30 31 const {_} = useLingui() 31 32 const {closeModal} = useModalControls() 32 33 const {isMobile} = useWebMediaQueries() ··· 39 40 setError('') 40 41 setIsProcessing(true) 41 42 try { 42 - await store.agent.com.atproto.server.requestAccountDelete() 43 + await agent.com.atproto.server.requestAccountDelete() 43 44 setIsEmailSent(true) 44 45 } catch (e: any) { 45 46 setError(cleanError(e)) ··· 47 48 setIsProcessing(false) 48 49 } 49 50 const onPressConfirmDelete = async () => { 51 + if (!currentAccount?.did) { 52 + throw new Error(`DeleteAccount modal: currentAccount.did is undefined`) 53 + } 54 + 50 55 setError('') 51 56 setIsProcessing(true) 52 57 const token = confirmCode.replace(/\s/g, '') 53 58 54 59 try { 55 - await store.agent.com.atproto.server.deleteAccount({ 56 - did: store.me.did, 60 + await agent.com.atproto.server.deleteAccount({ 61 + did: currentAccount.did, 57 62 password, 58 63 token, 59 64 }) 60 65 Toast.show('Your account has been deleted') 61 66 resetToTab('HomeTab') 62 - store.session.clear() 67 + removeAccount(currentAccount) 68 + clearCurrentAccount() 63 69 closeModal() 64 70 } catch (e: any) { 65 71 setError(cleanError(e)) ··· 88 94 pal.text, 89 95 s.bold, 90 96 ]}> 91 - {store.me.handle} 97 + {currentAccount?.handle} 92 98 </Text> 93 99 <Text type="title-xl" style={[pal.text, s.bold]}> 94 100 {'"'}
+3 -3
src/view/com/util/forms/PostDropdownBtn.tsx
··· 15 15 import {useModalControls} from '#/state/modals' 16 16 import {makeProfileLink} from '#/lib/routes/links' 17 17 import {getTranslatorLink} from '#/locale/helpers' 18 - import {useStores} from '#/state' 19 18 import {usePostDeleteMutation} from '#/state/queries/post' 20 19 import {useMutedThreads, useToggleThreadMute} from '#/state/muted-threads' 21 20 import {useLanguagePrefs} from '#/state/preferences' 22 21 import {logger} from '#/logger' 23 22 import {Shadow} from '#/state/cache/types' 23 + import {useSession} from '#/state/session' 24 24 25 25 export function PostDropdownBtn({ 26 26 testID, ··· 33 33 record: AppBskyFeedPost.Record 34 34 style?: StyleProp<ViewStyle> 35 35 }) { 36 - const store = useStores() 36 + const {currentAccount} = useSession() 37 37 const theme = useTheme() 38 38 const defaultCtrlColor = theme.palette.default.postCtrl 39 39 const {openModal} = useModalControls() ··· 44 44 45 45 const rootUri = record.reply?.root?.uri || post.uri 46 46 const isThreadMuted = mutedThreads.includes(rootUri) 47 - const isAuthor = post.author.did === store.me.did 47 + const isAuthor = post.author.did === currentAccount?.did 48 48 const href = React.useMemo(() => { 49 49 const urip = new AtUri(post.uri) 50 50 return makeProfileLink(post.author, 'post', urip.rkey)
+6 -4
src/view/shell/bottom-bar/BottomBar.tsx
··· 6 6 import {useSafeAreaInsets} from 'react-native-safe-area-context' 7 7 import {observer} from 'mobx-react-lite' 8 8 import {Text} from 'view/com/util/text/Text' 9 - import {useStores} from 'state/index' 10 9 import {useAnalytics} from 'lib/analytics/analytics' 11 10 import {clamp} from 'lib/numbers' 12 11 import { ··· 30 29 import {useShellLayout} from '#/state/shell/shell-layout' 31 30 import {useUnreadNotifications} from '#/state/queries/notifications/unread' 32 31 import {emitSoftReset} from '#/state/events' 32 + import {useSession} from '#/state/session' 33 + import {useProfileQuery} from '#/state/queries/profile' 33 34 34 35 type TabOptions = 'Home' | 'Search' | 'Notifications' | 'MyProfile' | 'Feeds' 35 36 ··· 37 38 navigation, 38 39 }: BottomTabBarProps) { 39 40 const {openModal} = useModalControls() 40 - const store = useStores() 41 + const {currentAccount} = useSession() 41 42 const pal = usePalette('default') 42 43 const {_} = useLingui() 43 44 const safeAreaInsets = useSafeAreaInsets() ··· 47 48 useNavigationTabState() 48 49 const numUnreadNotifications = useUnreadNotifications() 49 50 const {footerMinimalShellTransform} = useMinimalShellMode() 51 + const {data: profile} = useProfileQuery({did: currentAccount?.did}) 50 52 51 53 const onPressTab = React.useCallback( 52 54 (tab: TabOptions) => { ··· 203 205 {borderColor: pal.text.color}, 204 206 ]}> 205 207 <UserAvatar 206 - avatar={store.me.avatar} 208 + avatar={profile?.avatar} 207 209 size={27} 208 210 // See https://github.com/bluesky-social/social-app/pull/1801: 209 211 usePlainRNImage={true} ··· 212 214 ) : ( 213 215 <View style={[styles.ctrlIcon, pal.text, styles.profileIcon]}> 214 216 <UserAvatar 215 - avatar={store.me.avatar} 217 + avatar={profile?.avatar} 216 218 size={28} 217 219 // See https://github.com/bluesky-social/social-app/pull/1801: 218 220 usePlainRNImage={true}
+14 -5
src/view/shell/bottom-bar/BottomBarWeb.tsx
··· 1 1 import React from 'react' 2 2 import {observer} from 'mobx-react-lite' 3 - import {useStores} from 'state/index' 4 3 import {usePalette} from 'lib/hooks/usePalette' 5 4 import {useNavigationState} from '@react-navigation/native' 6 5 import Animated from 'react-native-reanimated' ··· 23 22 import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode' 24 23 import {makeProfileLink} from 'lib/routes/links' 25 24 import {CommonNavigatorParams} from 'lib/routes/types' 25 + import {useSession} from '#/state/session' 26 26 27 27 export const BottomBarWeb = observer(function BottomBarWebImpl() { 28 - const store = useStores() 28 + const {currentAccount} = useSession() 29 29 const pal = usePalette('default') 30 30 const safeAreaInsets = useSafeAreaInsets() 31 31 const {footerMinimalShellTransform} = useMinimalShellMode() ··· 88 88 ) 89 89 }} 90 90 </NavItem> 91 - <NavItem routeName="Profile" href={makeProfileLink(store.me)}> 91 + <NavItem 92 + routeName="Profile" 93 + href={ 94 + currentAccount 95 + ? makeProfileLink({ 96 + did: currentAccount.did, 97 + handle: currentAccount.handle, 98 + }) 99 + : '/' 100 + }> 92 101 {({isActive}) => { 93 102 const Icon = isActive ? UserIconSolid : UserIcon 94 103 return ( ··· 109 118 href: string 110 119 routeName: string 111 120 }> = ({children, href, routeName}) => { 121 + const {currentAccount} = useSession() 112 122 const currentRoute = useNavigationState(state => { 113 123 if (!state) { 114 124 return {name: 'Home'} 115 125 } 116 126 return getCurrentRoute(state) 117 127 }) 118 - const store = useStores() 119 128 const isActive = 120 129 currentRoute.name === 'Profile' 121 130 ? isTab(currentRoute.name, routeName) && 122 131 (currentRoute.params as CommonNavigatorParams['Profile']).name === 123 - store.me.handle 132 + currentAccount?.handle 124 133 : isTab(currentRoute.name, routeName) 125 134 126 135 return (