tweak to use intent
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import React from 'react'
|
||||
import {Alert} from 'react-native'
|
||||
import * as Linking from 'expo-linking'
|
||||
|
||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||
import {logEvent} from '#/lib/statsig/statsig'
|
||||
import {logger} from '#/logger'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {useSession} from '#/state/session'
|
||||
import {useCloseAllActiveElements} from '#/state/util'
|
||||
@@ -12,8 +13,10 @@ import {
|
||||
} from '#/components/ageAssurance/AgeAssuranceRedirectDialog'
|
||||
import {useIntentDialogs} from '#/components/intents/IntentDialogs'
|
||||
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+)?$/
|
||||
|
||||
@@ -27,12 +30,13 @@ export function useIntentHandler() {
|
||||
const ageAssuranceRedirectDialogControl =
|
||||
useAgeAssuranceRedirectDialogControl()
|
||||
const {currentAccount} = useSession()
|
||||
const {tryApplyUpdate} = useApplyPullRequestOTAUpdate()
|
||||
|
||||
React.useEffect(() => {
|
||||
const handleIncomingURL = (url: string) => {
|
||||
const referrerInfo = Referrer.getReferrerInfo()
|
||||
if (referrerInfo && referrerInfo.hostname !== 'bsky.app') {
|
||||
logEvent('deepLink:referrerReceived', {
|
||||
logger.metric('deepLink:referrerReceived', {
|
||||
to: url,
|
||||
referrer: referrerInfo?.referrer,
|
||||
hostname: referrerInfo?.hostname,
|
||||
@@ -92,6 +96,18 @@ export function useIntentHandler() {
|
||||
}
|
||||
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: {
|
||||
return
|
||||
}
|
||||
@@ -111,6 +127,7 @@ export function useIntentHandler() {
|
||||
verifyEmailIntent,
|
||||
ageAssuranceRedirectDialogControl,
|
||||
currentAccount,
|
||||
tryApplyUpdate,
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ export function useApplyPullRequestOTAUpdate() {
|
||||
const isCurrentlyRunningPullRequestDeployment =
|
||||
currentChannel?.startsWith('pull-request')
|
||||
|
||||
const onTryApplyUpdate = async (channel: string) => {
|
||||
const tryApplyUpdate = async (channel: string) => {
|
||||
setPending(true)
|
||||
if (currentChannel === channel) {
|
||||
const res = await checkForUpdateAsync()
|
||||
@@ -134,7 +134,7 @@ export function useApplyPullRequestOTAUpdate() {
|
||||
setPending(false)
|
||||
}
|
||||
|
||||
const onRevertToEmbedded = async () => {
|
||||
const revertToEmbedded = async () => {
|
||||
try {
|
||||
await updateTestflight()
|
||||
} catch (e: any) {
|
||||
@@ -143,8 +143,8 @@ export function useApplyPullRequestOTAUpdate() {
|
||||
}
|
||||
|
||||
return {
|
||||
onTryApplyUpdate,
|
||||
onRevertToEmbedded,
|
||||
tryApplyUpdate,
|
||||
revertToEmbedded,
|
||||
currentChannel,
|
||||
isCurrentlyRunningPullRequestDeployment,
|
||||
pending,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 {useReducedMotion} from 'react-native-reanimated'
|
||||
import {type AppBskyActorDefs, moderateProfile} from '@atproto/api'
|
||||
@@ -366,6 +366,11 @@ function DevOptions() {
|
||||
const onboardingDispatch = useOnboardingDispatch()
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
const {mutate: deleteChatDeclarationRecord} = useDeleteActorDeclaration()
|
||||
const {
|
||||
revertToEmbedded,
|
||||
isCurrentlyRunningPullRequestDeployment,
|
||||
currentChannel,
|
||||
} = useApplyPullRequestOTAUpdate()
|
||||
const [actyNotifNudged, setActyNotifNudged] = useActivitySubscriptionsNudged()
|
||||
|
||||
const resetOnboarding = async () => {
|
||||
@@ -394,41 +399,6 @@ function DevOptions() {
|
||||
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 (
|
||||
<>
|
||||
<SettingsList.PressableItem
|
||||
@@ -489,18 +459,9 @@ function DevOptions() {
|
||||
<Trans>Clear all storage data (restart after this)</Trans>
|
||||
</SettingsList.ItemText>
|
||||
</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 ? (
|
||||
<SettingsList.PressableItem
|
||||
onPress={onRevertToEmbedded}
|
||||
onPress={revertToEmbedded}
|
||||
label={_(msg`Unapply Pull Request`)}>
|
||||
<SettingsList.ItemText>
|
||||
<Trans>Unapply Pull Request {currentChannel}</Trans>
|
||||
|
||||
Reference in New Issue
Block a user