Bluesky app fork with some witchin' additions 💫

Merge pull request #9189 from internet-development/binaryfiddler/hashtag

prompt user to log in on hashtag screen

authored by

jim and committed by
GitHub
e4485da4 6c7fd965

+53 -2
+53 -2
src/screens/Hashtag.tsx
··· 1 1 import React from 'react' 2 2 import {type ListRenderItemInfo, View} from 'react-native' 3 3 import {type AppBskyFeedDefs} from '@atproto/api' 4 - import {msg} from '@lingui/macro' 4 + import {msg, Trans} from '@lingui/macro' 5 5 import {useLingui} from '@lingui/react' 6 6 import {useFocusEffect} from '@react-navigation/native' 7 7 import {type NativeStackScreenProps} from '@react-navigation/native-stack' ··· 14 14 import {sanitizeHandle} from '#/lib/strings/handles' 15 15 import {enforceLen} from '#/lib/strings/helpers' 16 16 import {useSearchPostsQuery} from '#/state/queries/search-posts' 17 + import {useSession} from '#/state/session' 17 18 import {useSetMinimalShellMode} from '#/state/shell' 19 + import {useLoggedOutViewControls} from '#/state/shell/logged-out' 20 + import {useCloseAllActiveElements} from '#/state/util' 18 21 import {Pager} from '#/view/com/pager/Pager' 19 22 import {TabBar} from '#/view/com/pager/TabBar' 20 23 import {Post} from '#/view/com/post/Post' 21 24 import {List} from '#/view/com/util/List' 22 - import {atoms as a, web} from '#/alf' 25 + import {atoms as a, useTheme, web} from '#/alf' 23 26 import {Button, ButtonIcon} from '#/components/Button' 24 27 import {ArrowOutOfBoxModified_Stroke2_Corner2_Rounded as Share} from '#/components/icons/ArrowOutOfBox' 25 28 import * as Layout from '#/components/Layout' 29 + import {InlineLinkText} from '#/components/Link' 26 30 import {ListFooter, ListMaybePlaceholder} from '#/components/Lists' 31 + import {SearchError} from '#/components/SearchError' 32 + import {Text} from '#/components/Typography' 27 33 28 34 const renderItem = ({item}: ListRenderItemInfo<AppBskyFeedDefs.PostView>) => { 29 35 return <Post post={item} /> ··· 161 167 const {_} = useLingui() 162 168 const initialNumToRender = useInitialNumToRender() 163 169 const [isPTR, setIsPTR] = React.useState(false) 170 + const t = useTheme() 171 + const {hasSession} = useSession() 164 172 165 173 const queryParam = React.useMemo(() => { 166 174 if (!author) return fullTag ··· 193 201 if (isFetchingNextPage || !hasNextPage || error) return 194 202 fetchNextPage() 195 203 }, [isFetchingNextPage, hasNextPage, error, fetchNextPage]) 204 + 205 + const closeAllActiveElements = useCloseAllActiveElements() 206 + const {requestSwitchToAccount} = useLoggedOutViewControls() 207 + 208 + const showSignIn = () => { 209 + closeAllActiveElements() 210 + requestSwitchToAccount({requestedAccount: 'none'}) 211 + } 212 + 213 + const showCreateAccount = () => { 214 + closeAllActiveElements() 215 + requestSwitchToAccount({requestedAccount: 'new'}) 216 + } 217 + 218 + if (!hasSession) { 219 + return ( 220 + <SearchError 221 + title={_(msg`Search is currently unavailable when logged out`)}> 222 + <Text style={[a.text_md, a.text_center, a.leading_snug]}> 223 + <Trans> 224 + <InlineLinkText 225 + label={_(msg`Sign in`)} 226 + to={'#'} 227 + onPress={showSignIn}> 228 + Sign in 229 + </InlineLinkText> 230 + <Text style={t.atoms.text_contrast_medium}> or </Text> 231 + <InlineLinkText 232 + label={_(msg`Create an account`)} 233 + to={'#'} 234 + onPress={showCreateAccount}> 235 + create an account 236 + </InlineLinkText> 237 + <Text> </Text> 238 + <Text style={t.atoms.text_contrast_medium}> 239 + to search for news, sports, politics, and everything else 240 + happening on Bluesky. 241 + </Text> 242 + </Trans> 243 + </Text> 244 + </SearchError> 245 + ) 246 + } 196 247 197 248 return ( 198 249 <>