Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix: try cache first for mobile notifications (#994)

Peter Chinman328e370dfda6
diff --git a/js/app/packages/notifications/components/NotificationRoute.tsx b/js/app/packages/notifications/components/NotificationRoute.tsx
index b62c4147d9..0657a9e3b9 100644
--- a/js/app/packages/notifications/components/NotificationRoute.tsx
+++ b/js/app/packages/notifications/components/NotificationRoute.tsx
@@ -1,3 +1,4 @@
+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { globalSplitManager } from '@app/signal/splitLayout';
import { LoadingBlock } from '@core/component/LoadingBlock';
@@ -38,13 +39,19 @@ export default function NotificationRoute() {
onCleanup(() => window.clearTimeout(timeout));
});
+ const notificationSource = useGlobalNotificationSource();
+
createEffect(() => {
const notificationId = getNotificationId();
const layoutManager = globalSplitManager();
if (!notificationId) return;
if (!layoutManager) return;
- openNotificationFromId(notificationId, layoutManager).match(
+ openNotificationFromId(
+ notificationId,
+ layoutManager,
+ notificationSource
+ ).match(
() => {
// We only use this route as a "bridge" from external navigation
// (e.g. push tap / deep link) into the split layout.
diff --git a/js/app/packages/notifications/notification-navigation.ts b/js/app/packages/notifications/notification-navigation.ts
index ab2e56337c..cc1ab76d24 100644
--- a/js/app/packages/notifications/notification-navigation.ts
+++ b/js/app/packages/notifications/notification-navigation.ts
@@ -10,6 +10,7 @@ import {
tryToTypedNotification,
type TypedNotification,
} from './notification-metadata';
+import type { NotificationSource } from './notification-source';
/**
* Notification event types that are all handled by opening a channel
@@ -193,8 +194,23 @@ export function openNotification(
export function openNotificationFromId(
notificationId: string,
- layoutManager: SplitManager
+ layoutManager: SplitManager,
+ notificationSource: NotificationSource
): ResultAsync<void, OpenNotificationFromIdError> {
+ // Check notification source first
+ const cached = notificationSource
+ .notifications()
+ .find((n) => n.id === notificationId);
+ if (cached) {
+ const typed = tryToTypedNotification(cached);
+ if (!typed) {
+ const err: NotTypedError = { tag: 'NotTypedError', notificationId };
+ return errAsync(err);
+ }
+ return openNotification(typed, layoutManager);
+ }
+
+ // Fetch if not in notification source
return ResultAsync.fromSafePromise(
getNotificationById(notificationId)
).andThen((unified) => {