disable sending of messages w/o verified email
This commit is contained in:
@@ -35,7 +35,6 @@ export function MessageProfileButton({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (needsEmailVerification) {
|
if (needsEmailVerification) {
|
||||||
console.log('open')
|
|
||||||
verifyEmailControl.open()
|
verifyEmailControl.open()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import {useKeyboardController} from 'react-native-keyboard-controller'
|
|||||||
import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api'
|
import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useFocusEffect} from '@react-navigation/native'
|
import {useFocusEffect, useNavigation} from '@react-navigation/native'
|
||||||
import {NativeStackScreenProps} from '@react-navigation/native-stack'
|
import {NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||||
|
|
||||||
import {CommonNavigatorParams} from '#/lib/routes/types'
|
import {useEmail} from '#/lib/hooks/useEmail'
|
||||||
|
import {CommonNavigatorParams, NavigationProp} from '#/lib/routes/types'
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
import {ConvoProvider, isConvoActive, useConvo} from '#/state/messages/convo'
|
import {ConvoProvider, isConvoActive, useConvo} from '#/state/messages/convo'
|
||||||
@@ -19,6 +20,8 @@ import {useSetMinimalShellMode} from '#/state/shell'
|
|||||||
import {CenteredView} from '#/view/com/util/Views'
|
import {CenteredView} from '#/view/com/util/Views'
|
||||||
import {MessagesList} from '#/screens/Messages/components/MessagesList'
|
import {MessagesList} from '#/screens/Messages/components/MessagesList'
|
||||||
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
||||||
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
|
import {VerifyEmailDialog} from '#/components/dialogs/VerifyEmailDialog'
|
||||||
import {MessagesListBlockedFooter} from '#/components/dms/MessagesListBlockedFooter'
|
import {MessagesListBlockedFooter} from '#/components/dms/MessagesListBlockedFooter'
|
||||||
import {MessagesListHeader} from '#/components/dms/MessagesListHeader'
|
import {MessagesListHeader} from '#/components/dms/MessagesListHeader'
|
||||||
import {Error} from '#/components/Error'
|
import {Error} from '#/components/Error'
|
||||||
@@ -161,8 +164,12 @@ function InnerReady({
|
|||||||
hasScrolled: boolean
|
hasScrolled: boolean
|
||||||
setHasScrolled: React.Dispatch<React.SetStateAction<boolean>>
|
setHasScrolled: React.Dispatch<React.SetStateAction<boolean>>
|
||||||
}) {
|
}) {
|
||||||
|
const {_} = useLingui()
|
||||||
const convoState = useConvo()
|
const convoState = useConvo()
|
||||||
|
const navigation = useNavigation<NavigationProp>()
|
||||||
const recipient = useProfileShadow(recipientUnshadowed)
|
const recipient = useProfileShadow(recipientUnshadowed)
|
||||||
|
const verifyEmailControl = useDialogControl()
|
||||||
|
const {needsEmailVerification} = useEmail()
|
||||||
|
|
||||||
const moderation = React.useMemo(() => {
|
const moderation = React.useMemo(() => {
|
||||||
return moderateProfile(recipient, moderationOpts)
|
return moderateProfile(recipient, moderationOpts)
|
||||||
@@ -179,6 +186,12 @@ function InnerReady({
|
|||||||
}
|
}
|
||||||
}, [moderation])
|
}, [moderation])
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (needsEmailVerification) {
|
||||||
|
verifyEmailControl.open()
|
||||||
|
}
|
||||||
|
}, [needsEmailVerification, verifyEmailControl])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MessagesListHeader
|
<MessagesListHeader
|
||||||
@@ -201,6 +214,15 @@ function InnerReady({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
<VerifyEmailDialog
|
||||||
|
reasonText={_(
|
||||||
|
msg`Before you may message another user, you must first verify your email.`,
|
||||||
|
)}
|
||||||
|
control={verifyEmailControl}
|
||||||
|
onCloseWithoutVerifying={() => {
|
||||||
|
navigation.navigate('Home')
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import Graphemer from 'graphemer'
|
|||||||
|
|
||||||
import {HITSLOP_10, MAX_DM_GRAPHEME_LENGTH} from '#/lib/constants'
|
import {HITSLOP_10, MAX_DM_GRAPHEME_LENGTH} from '#/lib/constants'
|
||||||
import {useHaptics} from '#/lib/haptics'
|
import {useHaptics} from '#/lib/haptics'
|
||||||
|
import {useEmail} from '#/lib/hooks/useEmail'
|
||||||
import {isIOS} from '#/platform/detection'
|
import {isIOS} from '#/platform/detection'
|
||||||
import {
|
import {
|
||||||
useMessageDraft,
|
useMessageDraft,
|
||||||
@@ -61,10 +62,15 @@ export function MessageInput({
|
|||||||
const [message, setMessage] = React.useState(getDraft)
|
const [message, setMessage] = React.useState(getDraft)
|
||||||
const inputRef = useAnimatedRef<TextInput>()
|
const inputRef = useAnimatedRef<TextInput>()
|
||||||
|
|
||||||
|
const {needsEmailVerification} = useEmail()
|
||||||
|
|
||||||
useSaveMessageDraft(message)
|
useSaveMessageDraft(message)
|
||||||
useExtractEmbedFromFacets(message, setEmbed)
|
useExtractEmbedFromFacets(message, setEmbed)
|
||||||
|
|
||||||
const onSubmit = React.useCallback(() => {
|
const onSubmit = React.useCallback(() => {
|
||||||
|
if (needsEmailVerification) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!hasEmbed && message.trim() === '') {
|
if (!hasEmbed && message.trim() === '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -84,6 +90,7 @@ export function MessageInput({
|
|||||||
inputRef.current?.focus()
|
inputRef.current?.focus()
|
||||||
}, 100)
|
}, 100)
|
||||||
}, [
|
}, [
|
||||||
|
needsEmailVerification,
|
||||||
hasEmbed,
|
hasEmbed,
|
||||||
message,
|
message,
|
||||||
clearDraft,
|
clearDraft,
|
||||||
@@ -159,6 +166,7 @@ export function MessageInput({
|
|||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
hitSlop={HITSLOP_10}
|
hitSlop={HITSLOP_10}
|
||||||
animatedProps={animatedProps}
|
animatedProps={animatedProps}
|
||||||
|
editable={!needsEmailVerification}
|
||||||
/>
|
/>
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
@@ -171,7 +179,8 @@ export function MessageInput({
|
|||||||
a.justify_center,
|
a.justify_center,
|
||||||
{height: 30, width: 30, backgroundColor: t.palette.primary_500},
|
{height: 30, width: 30, backgroundColor: t.palette.primary_500},
|
||||||
]}
|
]}
|
||||||
onPress={onSubmit}>
|
onPress={onSubmit}
|
||||||
|
disabled={needsEmailVerification}>
|
||||||
<PaperPlane fill={t.palette.white} style={[a.relative, {left: 1}]} />
|
<PaperPlane fill={t.palette.white} style={[a.relative, {left: 1}]} />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user