about summary refs log tree commit diff
path: root/src/lib/routes/helpers.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-12-05 18:01:08 -0800
committerGitHub <noreply@github.com>2023-12-05 18:01:08 -0800
commit826b841e105269952c00456240dd2978c7bc9d97 (patch)
tree0da3147c6a86882f7b91be0ebde0e75a493554ac /src/lib/routes/helpers.ts
parent3c8036587e28d8fc90e87e4818e3f4e080fbd091 (diff)
downloadvoidsky-826b841e105269952c00456240dd2978c7bc9d97.tar.zst
Fix: correctly identify if the screen is focused when handling soft resets on post feeds (#2100)
Diffstat (limited to 'src/lib/routes/helpers.ts')
-rw-r--r--src/lib/routes/helpers.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/routes/helpers.ts b/src/lib/routes/helpers.ts
index cdac9039a..7097f09bd 100644
--- a/src/lib/routes/helpers.ts
+++ b/src/lib/routes/helpers.ts
@@ -1,5 +1,15 @@
+import {NavigationProp} from '@react-navigation/native'
 import {State, RouteParams} from './types'
 
+export function getRootNavigation<T>(
+  nav: NavigationProp<T>,
+): NavigationProp<T> {
+  while (nav.getParent()) {
+    nav = nav.getParent()
+  }
+  return nav
+}
+
 export function getCurrentRoute(state: State) {
   let node = state.routes[state.index || 0]
   while (node.state?.routes && typeof node.state?.index === 'number') {