Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

[Chat] Gate groupchat screen (#10316)

authored by

Samuel Newman and committed by
GitHub
6d53459e 2ab1e2c9

+79 -8
+1
src/analytics/features/types.ts
··· 12 12 ImageUploadsHighResolution = 'image_uploads:high_resolution', 13 13 ImageUploadsBlobSize2mbEnabled = 'image_uploads:blob_size_2mb:enabled', 14 14 GroupChatsEnable = 'group_chats:enable', 15 + GroupChatsHasBeenReleased = 'group_chats:has_been_released', 15 16 DmsNewMessageComposerEnable = 'dms:new_message_composer:enable', 16 17 KlipyGifProviderEnable = 'klipy_gif_provider:enable', 17 18 PostGalleryEmbedEnable = 'post_gallery_embed:enable',
+78 -8
src/screens/Messages/Conversation.tsx
··· 6 6 ScrollEdgeEffect, 7 7 ScrollEdgeEffectProvider, 8 8 } from '@bsky.app/expo-scroll-edge-effect' 9 - import {msg} from '@lingui/core/macro' 10 - import {useLingui} from '@lingui/react' 11 - import {Trans} from '@lingui/react/macro' 9 + import {Trans, useLingui} from '@lingui/react/macro' 12 10 import { 13 11 type RouteProp, 14 12 useFocusEffect, ··· 37 35 import {atoms as a, useTheme, web} from '#/alf' 38 36 import {AgeRestrictedScreen} from '#/components/ageAssurance/AgeRestrictedScreen' 39 37 import {useAgeAssuranceCopy} from '#/components/ageAssurance/useAgeAssuranceCopy' 38 + import * as Dialog from '#/components/Dialog' 40 39 import { 41 40 EmailDialogScreenID, 42 41 useEmailDialogControl, ··· 47 46 import {Error} from '#/components/Error' 48 47 import * as Layout from '#/components/Layout' 49 48 import {Loader} from '#/components/Loader' 49 + import * as Prompt from '#/components/Prompt' 50 + import {Text} from '#/components/Typography' 51 + import {useAnalytics} from '#/analytics' 50 52 import {IS_LIQUID_GLASS, IS_WEB} from '#/env' 51 53 import {ChatDisabled} from './components/ChatDisabled' 52 54 ··· 56 58 > 57 59 58 60 export function MessagesConversationScreen(props: Props) { 59 - const {_} = useLingui() 61 + const {t: l} = useLingui() 60 62 const aaCopy = useAgeAssuranceCopy() 61 63 return ( 62 64 <AgeRestrictedScreen 63 - screenTitle={_(msg`Conversation`)} 65 + screenTitle={l`Conversation`} 64 66 infoText={aaCopy.chatsInfoText}> 65 67 <MessagesConversationScreenInner {...props} /> 66 68 </AgeRestrictedScreen> ··· 102 104 function Inner({convoId}: {convoId: string}) { 103 105 const t = useTheme() 104 106 const convoState = useConvo() 105 - const {_} = useLingui() 107 + const {t: l} = useLingui() 106 108 const {currentAccount} = useSession() 107 109 const isFocused = useIsFocused() 108 110 const {top: topInset} = useSafeAreaInsets() ··· 140 142 <MessagesListHeader convo={convo} /> 141 143 </Layout.Center> 142 144 <Error 143 - title={_(msg`Something went wrong`)} 144 - message={_(msg`We couldn't load this conversation`)} 145 + title={l`Something went wrong`} 146 + message={l`We couldn't load this conversation`} 145 147 onRetry={() => convoState.error.retry()} 146 148 sideBorders={false} 147 149 /> ··· 293 295 } 294 296 /> 295 297 )} 298 + 299 + {convo?.kind === 'group' && <GroupChatGate />} 296 300 </> 297 301 ) 298 302 } 303 + 304 + function GroupChatGate() { 305 + const {t: l} = useLingui() 306 + const ax = useAnalytics() 307 + const navigation = useNavigation<NavigationProp>() 308 + 309 + const groupChatGateDialogControl = Dialog.useDialogControl() 310 + 311 + const isGatedGroupChat = !ax.features.enabled(ax.features.GroupChatsEnable) 312 + 313 + useEffect(() => { 314 + if (isGatedGroupChat) { 315 + setTimeout(() => groupChatGateDialogControl.open()) 316 + } 317 + }, [isGatedGroupChat, groupChatGateDialogControl]) 318 + 319 + const hasBeenReleased = ax.features.enabled( 320 + ax.features.GroupChatsHasBeenReleased, 321 + ) 322 + 323 + const onGoBack = () => { 324 + if (navigation.canGoBack()) { 325 + navigation.goBack() 326 + } else { 327 + navigation.replace('Messages', {animation: 'pop'}) 328 + } 329 + } 330 + 331 + return ( 332 + <Prompt.Outer 333 + control={groupChatGateDialogControl} 334 + nativeOptions={{preventDismiss: true, preventExpansion: true}} 335 + testID="groupChatGateDialog"> 336 + <Prompt.Content> 337 + <View style={[a.w_full, a.align_center, a.py_2xl]}> 338 + <Text style={{fontSize: 48}} emoji> 339 + 🐴 340 + </Text> 341 + </View> 342 + <Prompt.TitleText> 343 + {hasBeenReleased ? ( 344 + <Trans>Group chats are now available</Trans> 345 + ) : ( 346 + <Trans>Group chats are not yet available</Trans> 347 + )} 348 + </Prompt.TitleText> 349 + <Prompt.DescriptionText> 350 + {hasBeenReleased ? ( 351 + <Trans>Update your app to the latest version to join in!</Trans> 352 + ) : ( 353 + <Trans> 354 + This feature isn't available to you yet. Please check back later. 355 + </Trans> 356 + )} 357 + </Prompt.DescriptionText> 358 + </Prompt.Content> 359 + <Prompt.Actions> 360 + <Prompt.Action 361 + cta={l`Go Back`} 362 + onPress={onGoBack} 363 + color="primary_subtle" 364 + /> 365 + </Prompt.Actions> 366 + </Prompt.Outer> 367 + ) 368 + }