File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 3
3
NativeCommand ,
4
4
WebAppAction ,
5
5
WebAppCommand ,
6
- parseActiveTab ,
7
6
} from '@tloncorp/shared' ;
8
7
import _ , { debounce } from 'lodash' ;
9
8
import { useEffect , useMemo , useState } from 'react' ;
@@ -20,6 +19,33 @@ const postJSONToNativeApp = (obj: Record<string, unknown>) => {
20
19
window . ReactNativeWebView ?. postMessage ( JSON . stringify ( obj ) ) ;
21
20
} ;
22
21
22
+ export function parseActiveTab ( pathname : string ) : MobileNavTab | null {
23
+ const parsedPath = trimFullPath ( pathname ) ;
24
+ const isActive = ( path : string ) => parsedPath . startsWith ( path ) ;
25
+
26
+ if ( isActive ( '/groups' ) ) {
27
+ return 'Groups' ;
28
+ }
29
+
30
+ if ( isActive ( '/messages' ) || isActive ( '/dm' ) ) {
31
+ return 'Messages' ;
32
+ }
33
+
34
+ if ( isActive ( '/profile' ) ) {
35
+ return 'Profile' ;
36
+ }
37
+
38
+ if ( isActive ( '/notifications' ) ) {
39
+ return 'Activity' ;
40
+ }
41
+
42
+ return null ;
43
+ }
44
+
45
+ export function trimFullPath ( path : string ) : string {
46
+ return path . startsWith ( '/apps/groups' ) ? path . slice ( 12 ) : path ;
47
+ }
48
+
23
49
export const postActionToNativeApp = ( action : WebAppAction , value ?: unknown ) =>
24
50
postJSONToNativeApp ( { action, value } ) ;
25
51
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ export {
29
29
allDraftInputs ,
30
30
allContentRenderers ,
31
31
} from './api/channelContentConfig' ;
32
- export { parseActiveTab , trimFullPath } from './logic/navigation' ;
33
32
export * from './logic' ;
34
33
export * from './store' ;
35
34
export * from './domain' ;
You can’t perform that action at this time.
0 commit comments