Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
import type { WithNotification } from '@entity/types/notification';
import { newestRowNotification } from './row-notification';
import type { UnifiedNotification } from './types';
export const DOCUMENT_COMMENT_EVENT_TYPES = [
'mentioned_in_document_comment',
'replied_to_document_comment_thread',
'commented_on_document',
] as const;
const isDocumentCommentTag = (tag: string) =>
(DOCUMENT_COMMENT_EVENT_TYPES as readonly string[]).includes(tag);
/**
* A document row can announce its newest outstanding event when it is a
* comment. Home supplies a cutoff so newer own activity cannot borrow an old
* comment's label or click target. Reading a comment does not dismiss it.
*/
export function getDocumentCommentNotification(
entity: WithNotification<{
type: string;
}>
): UnifiedNotification | undefined {
if (entity.type !== 'document') return undefined;
const notification = newestRowNotification(entity);
return notification &&
isDocumentCommentTag(notification.notification_metadata.tag)
? notification
: undefined;
}