|
@@ -1,5 +1,5 @@
|
|
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
|
-import { Linking, Platform } from 'react-native';
|
|
|
+import { Linking } from 'react-native';
|
|
|
import { useNavigation } from '@react-navigation/native';
|
|
|
import { NAVIGATION_PAGES } from 'src/types';
|
|
|
import { storage, StoreType } from 'src/storage';
|
|
@@ -17,13 +17,7 @@ const parseURL = (url: string) => {
|
|
|
return { path, queryParams };
|
|
|
};
|
|
|
|
|
|
-export const useNavigationContext = () => {
|
|
|
- const context = useContext(NavigationContext);
|
|
|
- if (!context) {
|
|
|
- throw new Error('useNavigationContext must be used within a NavigationProvider');
|
|
|
- }
|
|
|
- return context;
|
|
|
-};
|
|
|
+export const useNavigationContext = () => useContext(NavigationContext);
|
|
|
|
|
|
export const NavigationProvider = ({ children }: { children: React.ReactNode }) => {
|
|
|
const navigation = useNavigation();
|
|
@@ -32,14 +26,11 @@ export const NavigationProvider = ({ children }: { children: React.ReactNode })
|
|
|
|
|
|
const handleDeepLink = async (url?: string) => {
|
|
|
const link = url || (await Linking.getInitialURL());
|
|
|
- console.log('Deep Link URL:', link);
|
|
|
if (link) {
|
|
|
const { path } = parseURL(link);
|
|
|
- console.log('Parsed URL:', { path });
|
|
|
if (path.startsWith('/profile') && token) {
|
|
|
const segments = path.split('/');
|
|
|
const userId = segments[2];
|
|
|
- console.log('Navigating to public profile:', userId);
|
|
|
navigation.navigate(...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId }] as never));
|
|
|
}
|
|
|
}
|
|
@@ -54,7 +45,6 @@ export const NavigationProvider = ({ children }: { children: React.ReactNode })
|
|
|
}
|
|
|
|
|
|
const subscription = Linking.addEventListener('url', (event) => {
|
|
|
- console.log('Linking event:', event);
|
|
|
handleDeepLink(event.url);
|
|
|
});
|
|
|
|