about summary refs log tree commit diff
path: root/src/lib/hooks
diff options
context:
space:
mode:
authorAnsh <anshnanda10@gmail.com>2023-04-18 09:19:37 -0700
committerGitHub <noreply@github.com>2023-04-18 11:19:37 -0500
commit10621e86e4379ff05b2262a659b8512d80203a4b (patch)
treefdc91b7db00526f945d9463b732785da6cceb5c7 /src/lib/hooks
parent2509290fdd2b20c76c302d4962216f5d2d2b5a73 (diff)
downloadvoidsky-10621e86e4379ff05b2262a659b8512d80203a4b.tar.zst
APP-70 give profile its own tab mobile (#469)
* add prebuild command to package.json

* add ProfileTab navigator and screen

* add prop to remove back button from profile

* fix MyProfileTabNavigatorParams type

* fix dep array for rendering ProfileHeader

* just added ts-ignore

* enable opening drawer in profile tab

* clean up useNavigationTabState

* clean up code

* fix hideBackButton code flow
Diffstat (limited to 'src/lib/hooks')
-rw-r--r--src/lib/hooks/useNavigationTabState.ts15
-rw-r--r--src/lib/hooks/useNavigationTabState.web.ts1
2 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/hooks/useNavigationTabState.ts b/src/lib/hooks/useNavigationTabState.ts
index 8afc799eb..fb3662152 100644
--- a/src/lib/hooks/useNavigationTabState.ts
+++ b/src/lib/hooks/useNavigationTabState.ts
@@ -3,11 +3,24 @@ import {getTabState, TabState} from 'lib/routes/helpers'
 
 export function useNavigationTabState() {
   return useNavigationState(state => {
-    return {
+    const res = {
       isAtHome: getTabState(state, 'Home') !== TabState.Outside,
       isAtSearch: getTabState(state, 'Search') !== TabState.Outside,
       isAtNotifications:
         getTabState(state, 'Notifications') !== TabState.Outside,
+      isAtMyProfile: getTabState(state, 'MyProfile') !== TabState.Outside,
     }
+    if (
+      !res.isAtHome &&
+      !res.isAtNotifications &&
+      !res.isAtSearch &&
+      !res.isAtMyProfile
+    ) {
+      // HACK for some reason useNavigationState will give us pre-hydration results
+      //      and not update after, so we force isAtHome if all came back false
+      //      -prf
+      res.isAtHome = true
+    }
+    return res
   })
 }
diff --git a/src/lib/hooks/useNavigationTabState.web.ts b/src/lib/hooks/useNavigationTabState.web.ts
index d0173aa0f..704424781 100644
--- a/src/lib/hooks/useNavigationTabState.web.ts
+++ b/src/lib/hooks/useNavigationTabState.web.ts
@@ -8,6 +8,7 @@ export function useNavigationTabState() {
       isAtHome: currentRoute === 'Home',
       isAtSearch: currentRoute === 'Search',
       isAtNotifications: currentRoute === 'Notifications',
+      isAtMyProfile: currentRoute === 'MyProfile',
     }
   })
 }