Skip to content

Commit

Permalink
fix: fix transpilation circular dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
xlecunff-pass committed Nov 22, 2024
1 parent 8bf211b commit e47fa7a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/features/artist/pages/Artist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ export const Artist: FunctionComponent = () => {
<PageNotFound />
)
}

export default Artist
3 changes: 2 additions & 1 deletion src/features/deeplinks/helpers/getScreenFromDeeplink.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { linking } from 'features/navigation/RootNavigator/linking'
import { linkingPrefixes } from 'features/navigation/RootNavigator/linking/linkingPrefixes'
import { NavigationResultState } from 'features/navigation/RootNavigator/types'

import { DeeplinkParts } from '../types'

export function getScreenFromDeeplink(url: string): DeeplinkParts {
let pathWithQueryString = url
for (const prefix of linking.prefixes) {
for (const prefix of linkingPrefixes) {
pathWithQueryString = pathWithQueryString.replace(prefix, '')
}
const navigationState = linking.getStateFromPath(pathWithQueryString, linking.config)
Expand Down
10 changes: 2 additions & 8 deletions src/features/navigation/RootNavigator/linking/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import { LinkingOptions } from '@react-navigation/native'

import { linkingPrefixes } from 'features/navigation/RootNavigator/linking/linkingPrefixes'
import { rootScreensConfig } from 'features/navigation/RootNavigator/screens'
import { RootStackParamList } from 'features/navigation/RootNavigator/types'
import { WEBAPP_V2_URL } from 'libs/environment'
import { RequireField } from 'libs/typesUtils/typeHelpers'

import { getInitialURL } from './getInitialUrl'
import { customGetPathFromState } from './getPathFromState'
import { customGetStateFromPath } from './getStateFromPath'
import { subscribe } from './subscribe'

const PASS_CULTURE_PREFIX_URL = 'passculture://'

export const linking: RequireField<
LinkingOptions<RootStackParamList>,
'getStateFromPath' | 'getPathFromState'
> = {
prefixes: [
// must NOT be empty
WEBAPP_V2_URL,
PASS_CULTURE_PREFIX_URL,
],
prefixes: linkingPrefixes,
getInitialURL: getInitialURL,
subscribe: subscribe,
getStateFromPath: customGetStateFromPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WEBAPP_V2_URL } from 'libs/environment'

const PASS_CULTURE_PREFIX_URL = 'passculture://'

export const linkingPrefixes = [
// must NOT be empty
WEBAPP_V2_URL,
PASS_CULTURE_PREFIX_URL,
]
4 changes: 3 additions & 1 deletion src/features/navigation/RootNavigator/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Artist } from 'features/artist/pages/Artist'
import React from 'react'

const Artist = React.lazy(() => import('features/artist/pages/Artist'))
import { ForgottenPassword } from 'features/auth/pages/forgottenPassword/ForgottenPassword/ForgottenPassword'
import { ReinitializePassword } from 'features/auth/pages/forgottenPassword/ReinitializePassword/ReinitializePassword'
import { ResetPasswordEmailSent } from 'features/auth/pages/forgottenPassword/ResetPasswordEmailSent/ResetPasswordEmailSent'
Expand Down
4 changes: 2 additions & 2 deletions src/features/navigation/helpers/isAppUrl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { linking } from 'features/navigation/RootNavigator/linking'
import { linkingPrefixes } from 'features/navigation/RootNavigator/linking/linkingPrefixes'

export const isAppUrl = (url: string) => {
for (const prefix of linking.prefixes) {
for (const prefix of linkingPrefixes) {
if (url.match('^' + prefix)) {
return true
}
Expand Down
5 changes: 3 additions & 2 deletions src/features/navigation/helpers/openUrl.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Alert, Linking, NativeModules, Platform } from 'react-native'

import { getScreenFromDeeplink } from 'features/deeplinks/helpers'
import { navigateFromRef } from 'features/navigation/navigationRef'
import { analytics } from 'libs/analytics'
import { OfferAnalyticsData } from 'libs/analytics/logEventAnalytics'

import { isAppUrl } from './isAppUrl'
import { navigateToHome } from './navigateToHome'

const openAppUrl = (url: string) => {
const openAppUrl = async (url: string) => {
const { getScreenFromDeeplink } = await import('features/deeplinks/helpers')

try {
const { screen, params } = getScreenFromDeeplink(url)
return navigateFromRef(screen, params)
Expand Down

0 comments on commit e47fa7a

Please sign in to comment.