mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

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

[Video] require email to post videos (#5152)

Co-authored-by: Hailey <me@haileyok.com>

authored by samuel.fm

Hailey and committed by
GitHub
11792635 91c3dbd8

+68 -21
+5 -2
src/components/Prompt.tsx
··· 8 8 import * as Dialog from '#/components/Dialog' 9 9 import {Text} from '#/components/Typography' 10 10 11 - export {useDialogControl as usePromptControl} from '#/components/Dialog' 11 + export { 12 + type DialogControlProps as PromptControlProps, 13 + useDialogControl as usePromptControl, 14 + } from '#/components/Dialog' 12 15 13 16 const Context = React.createContext<{ 14 17 titleId: string ··· 23 26 control, 24 27 testID, 25 28 }: React.PropsWithChildren<{ 26 - control: Dialog.DialogOuterProps['control'] 29 + control: Dialog.DialogControlProps 27 30 testID?: string 28 31 }>) { 29 32 const {gtMobile} = useBreakpoints()
+63 -19
src/view/com/composer/videos/SelectVideoBtn.tsx
··· 1 1 import React, {useCallback} from 'react' 2 + import {Keyboard} from 'react-native' 2 3 import { 3 4 ImagePickerAsset, 4 5 launchImageLibraryAsync, ··· 10 11 11 12 import {useVideoLibraryPermission} from '#/lib/hooks/usePermissions' 12 13 import {isNative} from '#/platform/detection' 14 + import {useModalControls} from '#/state/modals' 15 + import {useSession} from '#/state/session' 13 16 import {atoms as a, useTheme} from '#/alf' 14 17 import {Button} from '#/components/Button' 15 18 import {VideoClip_Stroke2_Corner0_Rounded as VideoClipIcon} from '#/components/icons/VideoClip' 19 + import * as Prompt from '#/components/Prompt' 16 20 17 - const VIDEO_MAX_DURATION = 90 21 + const VIDEO_MAX_DURATION = 60 18 22 19 23 type Props = { 20 24 onSelectVideo: (video: ImagePickerAsset) => void ··· 26 30 const {_} = useLingui() 27 31 const t = useTheme() 28 32 const {requestVideoAccessIfNeeded} = useVideoLibraryPermission() 33 + const control = Prompt.usePromptControl() 34 + const {currentAccount} = useSession() 29 35 30 36 const onPressSelectVideo = useCallback(async () => { 31 37 if (isNative && !(await requestVideoAccessIfNeeded())) { 32 38 return 33 39 } 34 40 35 - const response = await launchImageLibraryAsync({ 36 - exif: false, 37 - mediaTypes: MediaTypeOptions.Videos, 38 - videoMaxDuration: VIDEO_MAX_DURATION, 39 - quality: 1, 40 - legacy: true, 41 - preferredAssetRepresentationMode: 42 - UIImagePickerPreferredAssetRepresentationMode.Current, 43 - }) 44 - if (response.assets && response.assets.length > 0) { 45 - try { 46 - onSelectVideo(response.assets[0]) 47 - } catch (err) { 48 - if (err instanceof Error) { 49 - setError(err.message) 50 - } else { 51 - setError(_(msg`An error occurred while selecting the video`)) 41 + if (!currentAccount?.emailConfirmed) { 42 + Keyboard.dismiss() 43 + control.open() 44 + } else { 45 + const response = await launchImageLibraryAsync({ 46 + exif: false, 47 + mediaTypes: MediaTypeOptions.Videos, 48 + videoMaxDuration: VIDEO_MAX_DURATION, 49 + quality: 1, 50 + legacy: true, 51 + preferredAssetRepresentationMode: 52 + UIImagePickerPreferredAssetRepresentationMode.Current, 53 + }) 54 + if (response.assets && response.assets.length > 0) { 55 + try { 56 + onSelectVideo(response.assets[0]) 57 + } catch (err) { 58 + if (err instanceof Error) { 59 + setError(err.message) 60 + } else { 61 + setError(_(msg`An error occurred while selecting the video`)) 62 + } 52 63 } 53 64 } 54 65 } 55 - }, [onSelectVideo, requestVideoAccessIfNeeded, setError, _]) 66 + }, [ 67 + onSelectVideo, 68 + requestVideoAccessIfNeeded, 69 + setError, 70 + _, 71 + control, 72 + currentAccount?.emailConfirmed, 73 + ]) 56 74 57 75 return ( 58 76 <> ··· 71 89 style={disabled && t.atoms.text_contrast_low} 72 90 /> 73 91 </Button> 92 + <VerifyEmailPrompt control={control} /> 74 93 </> 75 94 ) 76 95 } 96 + 97 + function VerifyEmailPrompt({control}: {control: Prompt.PromptControlProps}) { 98 + const {_} = useLingui() 99 + const {openModal} = useModalControls() 100 + 101 + return ( 102 + <Prompt.Basic 103 + control={control} 104 + title={_(msg`Verified email required`)} 105 + description={_( 106 + msg`To upload videos to Bluesky, you must first verify your email.`, 107 + )} 108 + confirmButtonCta={_(msg`Verify now`)} 109 + confirmButtonColor="primary" 110 + onConfirm={() => { 111 + control.close(() => { 112 + openModal({ 113 + name: 'verify-email', 114 + showReminder: false, 115 + }) 116 + }) 117 + }} 118 + /> 119 + ) 120 + }