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(channel): mark message notification viewed when it arrives after mount (#2707)

gbirman9303faa4e825
diff --git a/js/app/packages/notifications/components/MarkMessageNotifications.tsx b/js/app/packages/notifications/components/MarkMessageNotifications.tsx
index a87f55cd7c..0ac71d9b3a 100644
--- a/js/app/packages/notifications/components/MarkMessageNotifications.tsx
+++ b/js/app/packages/notifications/components/MarkMessageNotifications.tsx
@@ -1,4 +1,4 @@
-import { onCleanup, onMount } from 'solid-js';
+import { createEffect } from 'solid-js';
import type { JSXElement } from 'solid-js';
import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import type { UnifiedNotification } from '@notifications/types';
@@ -21,24 +21,13 @@ export function MarkMessageNotifications(props: {
isChannelNotification(n) &&
n.notification_metadata.content.messageId === props.messageId;
- let unsubscribe: () => void = () => {};
- onCleanup(() => {
- unsubscribe();
- });
+ let marked = false;
- onMount(() => {
+ createEffect(() => {
+ if (marked) return;
const existing = notifications().find(isMessageNotification);
-
- if (!existing) {
- unsubscribe = notificationSource.subscribe((n) => {
- if (!isMessageNotification(n)) return;
- notificationSource.markAsRead(n);
- unsubscribe();
- });
- return;
- }
-
- if (!existing.viewed_at) {
+ if (existing && !existing.viewed_at) {
+ marked = true;
notificationSource.markAsRead(existing);
}
});