Skip to content

Commit aed5f4a

Browse files
committed
fix web tests
1 parent a047940 commit aed5f4a

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

apps/tlon-web/src/logic/native.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
NativeCommand,
44
WebAppAction,
55
WebAppCommand,
6-
parseActiveTab,
76
} from '@tloncorp/shared';
87
import _, { debounce } from 'lodash';
98
import { useEffect, useMemo, useState } from 'react';
@@ -20,6 +19,33 @@ const postJSONToNativeApp = (obj: Record<string, unknown>) => {
2019
window.ReactNativeWebView?.postMessage(JSON.stringify(obj));
2120
};
2221

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+
2349
export const postActionToNativeApp = (action: WebAppAction, value?: unknown) =>
2450
postJSONToNativeApp({ action, value });
2551

packages/shared/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export {
2929
allDraftInputs,
3030
allContentRenderers,
3131
} from './api/channelContentConfig';
32-
export { parseActiveTab, trimFullPath } from './logic/navigation';
3332
export * from './logic';
3433
export * from './store';
3534
export * from './domain';

0 commit comments

Comments
 (0)