tweak to use intent
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import {Alert} from 'react-native'
|
||||||
import * as Linking from 'expo-linking'
|
import * as Linking from 'expo-linking'
|
||||||
|
|
||||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
import {logger} from '#/logger'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {useCloseAllActiveElements} from '#/state/util'
|
import {useCloseAllActiveElements} from '#/state/util'
|
||||||
@@ -12,8 +13,10 @@ import {
|
|||||||
} from '#/components/ageAssurance/AgeAssuranceRedirectDialog'
|
} from '#/components/ageAssurance/AgeAssuranceRedirectDialog'
|
||||||
import {useIntentDialogs} from '#/components/intents/IntentDialogs'
|
import {useIntentDialogs} from '#/components/intents/IntentDialogs'
|
||||||
import {Referrer} from '../../../modules/expo-bluesky-swiss-army'
|
import {Referrer} from '../../../modules/expo-bluesky-swiss-army'
|
||||||
|
import {IS_TESTFLIGHT} from '../app-info.web'
|
||||||
|
import {useApplyPullRequestOTAUpdate} from './useOTAUpdates'
|
||||||
|
|
||||||
type IntentType = 'compose' | 'verify-email' | 'age-assurance'
|
type IntentType = 'compose' | 'verify-email' | 'age-assurance' | 'apply-ota'
|
||||||
|
|
||||||
const VALID_IMAGE_REGEX = /^[\w.:\-_/]+\|\d+(\.\d+)?\|\d+(\.\d+)?$/
|
const VALID_IMAGE_REGEX = /^[\w.:\-_/]+\|\d+(\.\d+)?\|\d+(\.\d+)?$/
|
||||||
|
|
||||||
@@ -27,12 +30,13 @@ export function useIntentHandler() {
|
|||||||
const ageAssuranceRedirectDialogControl =
|
const ageAssuranceRedirectDialogControl =
|
||||||
useAgeAssuranceRedirectDialogControl()
|
useAgeAssuranceRedirectDialogControl()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {tryApplyUpdate} = useApplyPullRequestOTAUpdate()
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const handleIncomingURL = (url: string) => {
|
const handleIncomingURL = (url: string) => {
|
||||||
const referrerInfo = Referrer.getReferrerInfo()
|
const referrerInfo = Referrer.getReferrerInfo()
|
||||||
if (referrerInfo && referrerInfo.hostname !== 'bsky.app') {
|
if (referrerInfo && referrerInfo.hostname !== 'bsky.app') {
|
||||||
logEvent('deepLink:referrerReceived', {
|
logger.metric('deepLink:referrerReceived', {
|
||||||
to: url,
|
to: url,
|
||||||
referrer: referrerInfo?.referrer,
|
referrer: referrerInfo?.referrer,
|
||||||
hostname: referrerInfo?.hostname,
|
hostname: referrerInfo?.hostname,
|
||||||
@@ -92,6 +96,18 @@ export function useIntentHandler() {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
case 'apply-ota': {
|
||||||
|
if (!IS_TESTFLIGHT) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const channel = params.get('channel')
|
||||||
|
if (!channel) {
|
||||||
|
Alert.alert('Error', 'No channel provided to look for.')
|
||||||
|
} else {
|
||||||
|
tryApplyUpdate(channel)
|
||||||
|
}
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -111,6 +127,7 @@ export function useIntentHandler() {
|
|||||||
verifyEmailIntent,
|
verifyEmailIntent,
|
||||||
ageAssuranceRedirectDialogControl,
|
ageAssuranceRedirectDialogControl,
|
||||||
currentAccount,
|
currentAccount,
|
||||||
|
tryApplyUpdate,
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export function useApplyPullRequestOTAUpdate() {
|
|||||||
const isCurrentlyRunningPullRequestDeployment =
|
const isCurrentlyRunningPullRequestDeployment =
|
||||||
currentChannel?.startsWith('pull-request')
|
currentChannel?.startsWith('pull-request')
|
||||||
|
|
||||||
const onTryApplyUpdate = async (channel: string) => {
|
const tryApplyUpdate = async (channel: string) => {
|
||||||
setPending(true)
|
setPending(true)
|
||||||
if (currentChannel === channel) {
|
if (currentChannel === channel) {
|
||||||
const res = await checkForUpdateAsync()
|
const res = await checkForUpdateAsync()
|
||||||
@@ -134,7 +134,7 @@ export function useApplyPullRequestOTAUpdate() {
|
|||||||
setPending(false)
|
setPending(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onRevertToEmbedded = async () => {
|
const revertToEmbedded = async () => {
|
||||||
try {
|
try {
|
||||||
await updateTestflight()
|
await updateTestflight()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@@ -143,8 +143,8 @@ export function useApplyPullRequestOTAUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
onTryApplyUpdate,
|
tryApplyUpdate,
|
||||||
onRevertToEmbedded,
|
revertToEmbedded,
|
||||||
currentChannel,
|
currentChannel,
|
||||||
isCurrentlyRunningPullRequestDeployment,
|
isCurrentlyRunningPullRequestDeployment,
|
||||||
pending,
|
pending,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {useState} from 'react'
|
import {useState} from 'react'
|
||||||
import {Alert, LayoutAnimation, Pressable, View} from 'react-native'
|
import {LayoutAnimation, Pressable, View} from 'react-native'
|
||||||
import {Linking} from 'react-native'
|
import {Linking} from 'react-native'
|
||||||
import {useReducedMotion} from 'react-native-reanimated'
|
import {useReducedMotion} from 'react-native-reanimated'
|
||||||
import {type AppBskyActorDefs, moderateProfile} from '@atproto/api'
|
import {type AppBskyActorDefs, moderateProfile} from '@atproto/api'
|
||||||
@@ -366,6 +366,11 @@ function DevOptions() {
|
|||||||
const onboardingDispatch = useOnboardingDispatch()
|
const onboardingDispatch = useOnboardingDispatch()
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
const {mutate: deleteChatDeclarationRecord} = useDeleteActorDeclaration()
|
const {mutate: deleteChatDeclarationRecord} = useDeleteActorDeclaration()
|
||||||
|
const {
|
||||||
|
revertToEmbedded,
|
||||||
|
isCurrentlyRunningPullRequestDeployment,
|
||||||
|
currentChannel,
|
||||||
|
} = useApplyPullRequestOTAUpdate()
|
||||||
const [actyNotifNudged, setActyNotifNudged] = useActivitySubscriptionsNudged()
|
const [actyNotifNudged, setActyNotifNudged] = useActivitySubscriptionsNudged()
|
||||||
|
|
||||||
const resetOnboarding = async () => {
|
const resetOnboarding = async () => {
|
||||||
@@ -394,41 +399,6 @@ function DevOptions() {
|
|||||||
setActyNotifNudged(false)
|
setActyNotifNudged(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
|
||||||
onTryApplyUpdate,
|
|
||||||
onRevertToEmbedded,
|
|
||||||
isCurrentlyRunningPullRequestDeployment,
|
|
||||||
currentChannel,
|
|
||||||
} = useApplyPullRequestOTAUpdate()
|
|
||||||
|
|
||||||
const onPressApplyPullRequest = async () => {
|
|
||||||
Alert.prompt(
|
|
||||||
'Apply Pull Request',
|
|
||||||
"Enter a channel name below to apply a pull request. Channel names usually look like 'pull-request-<PULL REQUEST ID>'",
|
|
||||||
[
|
|
||||||
{
|
|
||||||
text: 'Cancel',
|
|
||||||
style: 'cancel',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Apply',
|
|
||||||
style: 'default',
|
|
||||||
onPress: async channel => {
|
|
||||||
if (!channel) {
|
|
||||||
Alert.alert('Error', 'No channel provided to look for.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await onTryApplyUpdate(channel ?? '')
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'plain-text',
|
|
||||||
isCurrentlyRunningPullRequestDeployment
|
|
||||||
? currentChannel
|
|
||||||
: 'pull-request-',
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SettingsList.PressableItem
|
<SettingsList.PressableItem
|
||||||
@@ -489,18 +459,9 @@ function DevOptions() {
|
|||||||
<Trans>Clear all storage data (restart after this)</Trans>
|
<Trans>Clear all storage data (restart after this)</Trans>
|
||||||
</SettingsList.ItemText>
|
</SettingsList.ItemText>
|
||||||
</SettingsList.PressableItem>
|
</SettingsList.PressableItem>
|
||||||
{isNative ? (
|
|
||||||
<SettingsList.PressableItem
|
|
||||||
onPress={onPressApplyPullRequest}
|
|
||||||
label={_(msg`Apply Pull Request`)}>
|
|
||||||
<SettingsList.ItemText>
|
|
||||||
<Trans>Apply Pull Request</Trans>
|
|
||||||
</SettingsList.ItemText>
|
|
||||||
</SettingsList.PressableItem>
|
|
||||||
) : null}
|
|
||||||
{isNative && isCurrentlyRunningPullRequestDeployment ? (
|
{isNative && isCurrentlyRunningPullRequestDeployment ? (
|
||||||
<SettingsList.PressableItem
|
<SettingsList.PressableItem
|
||||||
onPress={onRevertToEmbedded}
|
onPress={revertToEmbedded}
|
||||||
label={_(msg`Unapply Pull Request`)}>
|
label={_(msg`Unapply Pull Request`)}>
|
||||||
<SettingsList.ItemText>
|
<SettingsList.ItemText>
|
||||||
<Trans>Unapply Pull Request {currentChannel}</Trans>
|
<Trans>Unapply Pull Request {currentChannel}</Trans>
|
||||||
|
|||||||
Reference in New Issue
Block a user