Create logged-out view for group chat invites (#10598)
Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
import {sanitizeUrl} from '@braintree/sanitize-url'
|
||||
import {StackActions} from '@react-navigation/native'
|
||||
|
||||
import {useGroupChatJoinIntent} from '#/lib/hooks/useIntentHandler'
|
||||
import {
|
||||
type DebouncedNavigationProp,
|
||||
useNavigationDeduped,
|
||||
@@ -21,6 +22,7 @@ import {useOpenLink} from '#/lib/hooks/useOpenLink'
|
||||
import {getTabState, TabState} from '#/lib/routes/helpers'
|
||||
import {
|
||||
convertBskyAppUrlIfNeeded,
|
||||
getChatInviteCodeFromUrl,
|
||||
isExternalUrl,
|
||||
linkRequiresWarning,
|
||||
} from '#/lib/strings/url-helpers'
|
||||
@@ -81,6 +83,7 @@ export const Link = memo(function Link({
|
||||
const navigation = useNavigationDeduped()
|
||||
const anchorHref = asAnchor ? sanitizeUrl(href) : undefined
|
||||
const openLink = useOpenLink()
|
||||
const groupChatJoinIntent = useGroupChatJoinIntent()
|
||||
|
||||
const onPress = useCallback(
|
||||
(e?: Event) => {
|
||||
@@ -92,11 +95,20 @@ export const Link = memo(function Link({
|
||||
sanitizeUrl(href),
|
||||
navigationAction,
|
||||
openLink,
|
||||
groupChatJoinIntent,
|
||||
e,
|
||||
)
|
||||
}
|
||||
},
|
||||
[closeModal, navigation, navigationAction, href, openLink, onBeforePress],
|
||||
[
|
||||
closeModal,
|
||||
navigation,
|
||||
navigationAction,
|
||||
href,
|
||||
openLink,
|
||||
onBeforePress,
|
||||
groupChatJoinIntent,
|
||||
],
|
||||
)
|
||||
|
||||
const accessibilityActionsWithActivate = [
|
||||
@@ -196,6 +208,7 @@ export const TextLink = memo(function TextLink({
|
||||
const {closeModal} = useModalControls()
|
||||
const {linkWarningDialogControl} = useGlobalDialogsControlContext()
|
||||
const openLink = useOpenLink()
|
||||
const groupChatJoinIntent = useGroupChatJoinIntent()
|
||||
|
||||
if (!disableMismatchWarning && typeof text !== 'string') {
|
||||
console.error('Unable to detect mismatching label')
|
||||
@@ -238,6 +251,7 @@ export const TextLink = memo(function TextLink({
|
||||
sanitizeUrl(href),
|
||||
navigationAction,
|
||||
openLink,
|
||||
groupChatJoinIntent,
|
||||
e,
|
||||
)
|
||||
},
|
||||
@@ -252,6 +266,7 @@ export const TextLink = memo(function TextLink({
|
||||
navigationAction,
|
||||
openLink,
|
||||
linkWarningDialogControl,
|
||||
groupChatJoinIntent,
|
||||
],
|
||||
)
|
||||
const hrefAttrs = useMemo(() => {
|
||||
@@ -373,6 +388,7 @@ function onPressInner(
|
||||
href: string,
|
||||
navigationAction: 'push' | 'replace' | 'navigate' = 'push',
|
||||
openLink: (href: string) => void,
|
||||
groupChatJoinIntent: (code: string, uri?: string) => void,
|
||||
e?: Event,
|
||||
) {
|
||||
let shouldHandle = false
|
||||
@@ -400,6 +416,11 @@ function onPressInner(
|
||||
|
||||
if (shouldHandle) {
|
||||
href = convertBskyAppUrlIfNeeded(href)
|
||||
const chatInviteCode = getChatInviteCodeFromUrl(href)
|
||||
if (chatInviteCode) {
|
||||
groupChatJoinIntent(chatInviteCode, href)
|
||||
return
|
||||
}
|
||||
if (
|
||||
newTab ||
|
||||
href.startsWith('http') ||
|
||||
|
||||
Reference in New Issue
Block a user