Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/canary #3842

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ android {
applicationIdSuffix ".dev"
versionNameSuffix "-dev"
// 10203010 <- 10203(v1.2.3 version name)+01(build number)+0(Android app)
versionCode 80200040
versionCode 80200050
versionName "8.2.0"
}
prod {
Expand Down
2 changes: 1 addition & 1 deletion android/wearable/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
applicationIdSuffix = ".dev"
versionNameSuffix = "-dev"
// 10203011 <- 10203(v1.2.3 version name)+01(build number)+1(Wearable app)
versionCode = 80200041
versionCode = 80200051
versionName = "8.2.0"
}
create("prod") {
Expand Down
20 changes: 14 additions & 6 deletions src/hooks/useDeepLink.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as Linking from 'expo-linking'
import { useEffect } from 'react'
import { useCallback, useEffect } from 'react'
import { useOpenRouteFromLink } from './useOpenRouteFromLink'

export const useDeepLink = () => {
const url = Linking.useURL()
const { openLink: openRoute } = useOpenRouteFromLink()

useEffect(() => {
const getUrlAsync = async () => {
const handleURL = useCallback(
async (event: Linking.EventType) => {
const url = event.url
if (url && (await Linking.canOpenURL(url))) {
const parsedUrl = Linking.parse(url)
if (parsedUrl.queryParams) {
Expand Down Expand Up @@ -36,7 +36,15 @@ export const useDeepLink = () => {
})
}
}
},
[openRoute]
)

useEffect(() => {
const listener = Linking.addEventListener('url', handleURL)

return () => {
listener.remove()
}
getUrlAsync()
}, [openRoute, url])
}, [handleURL])
}
21 changes: 3 additions & 18 deletions src/hooks/useOpenRouteFromLink.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMutation } from '@connectrpc/connect-query'
import { useNavigation } from '@react-navigation/native'
import { useCallback } from 'react'
import { useRecoilState, useSetRecoilState } from 'recoil'
import { useSetRecoilState } from 'recoil'
import {
getStationsByLineGroupId,
getStationsByLineId,
Expand All @@ -15,13 +15,11 @@ import { LineDirection } from '../models/Bound'
import lineState from '../store/atoms/line'
import navigationState from '../store/atoms/navigation'
import stationState from '../store/atoms/station'
import { useResetMainState } from './useResetMainState'

export const useOpenRouteFromLink = () => {
const navigation = useNavigation()
const resetState = useResetMainState()

const [{ selectedBound }, setStationState] = useRecoilState(stationState)
const setStationState = useSetRecoilState(stationState)
const setNavigationState = useSetRecoilState(navigationState)
const setLineState = useSetRecoilState(lineState)

Expand All @@ -42,17 +40,11 @@ export const useOpenRouteFromLink = () => {
stations: Station[],
direction: LineDirection | null
) => {
if (selectedBound) {
return
}

const line = station?.line
if (!line) {
return
}

resetState()

setStationState((prev) => ({
...prev,
stations,
Expand All @@ -74,14 +66,7 @@ export const useOpenRouteFromLink = () => {
}))
navigation.navigate('Main')
},
[
navigation,
resetState,
selectedBound,
setLineState,
setNavigationState,
setStationState,
]
[navigation, setLineState, setNavigationState, setStationState]
)

const openLink = useCallback(
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useResetMainState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const useResetMainState = () => {
bottomState: 'LINE',
leftStations: [],
stationForHeader: null,
fromBuilder: false,
}))
setStationState((prev) => ({
...prev,
Expand Down
Loading