Live video on the AT Protocol
79
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v0.9.5 58 lines 1.5 kB view raw
1/** 2 * Navigator structure mapping - defines which routes belong to which parent navigators 3 */ 4const NAVIGATOR_STRUCTURE: Record<string, string[]> = { 5 Home: ["StreamList", "Stream"], 6 Settings: [ 7 "MainSettings", 8 "AboutCategory", 9 "AccountCategory", 10 "StreamingCategory", 11 "WebhooksSettings", 12 "PrivacyCategory", 13 "DanmuCategory", 14 "AdvancedCategory", 15 "LanguagesCategory", 16 "DeveloperSettings", 17 "KeyManagement", 18 ], 19}; 20 21/** 22 * Finds the parent navigator for a given route name 23 */ 24function findParentNavigator(routeName: string): string | null { 25 for (const [parent, children] of Object.entries(NAVIGATOR_STRUCTURE)) { 26 if (children.includes(routeName)) { 27 return parent; 28 } 29 } 30 return null; 31} 32 33/** 34 * Navigates to a route, automatically handling nested navigators 35 */ 36export function navigateToRoute( 37 navigation: any, 38 route: { name: string; params?: any }, 39) { 40 const parent = findParentNavigator(route.name); 41 42 if (parent) { 43 // nested route - navigate to parent with screen param 44 console.log( 45 `navigateToRoute: ${route.name} is nested in ${parent}, navigating with screen param`, 46 ); 47 (navigation.navigate as any)(parent, { 48 screen: route.name, 49 params: route.params, 50 }); 51 } else { 52 // top-level route - navigate directly 53 console.log( 54 `navigateToRoute: ${route.name} is top-level, navigating directly`, 55 ); 56 (navigation.navigate as any)(route.name, route.params); 57 } 58}