2026-04-29 04:12:42 +05:30
|
|
|
type MentionKeyInput = {
|
|
|
|
|
id: number;
|
|
|
|
|
document_type?: string | null;
|
2026-05-26 21:52:04 +05:30
|
|
|
connector_type?: string | null;
|
2026-06-23 18:30:22 +02:00
|
|
|
kind?: "doc" | "folder" | "connector" | "thread";
|
2026-04-29 04:12:42 +05:30
|
|
|
};
|
|
|
|
|
|
2026-05-09 22:15:51 -07:00
|
|
|
/**
|
|
|
|
|
* Build a stable dedup key for a mention chip.
|
|
|
|
|
*
|
2026-05-26 21:52:04 +05:30
|
|
|
* Each mention kind keys off its real identity fields:
|
2026-06-23 18:30:22 +02:00
|
|
|
* docs by document type, folders by folder id, connectors by
|
|
|
|
|
* connector type + account id, and threads by thread id.
|
2026-05-09 22:15:51 -07:00
|
|
|
*/
|
2026-04-29 04:12:42 +05:30
|
|
|
export function getMentionDocKey(doc: MentionKeyInput): string {
|
2026-05-09 22:15:51 -07:00
|
|
|
const kind = doc.kind ?? "doc";
|
2026-05-26 21:52:04 +05:30
|
|
|
if (kind === "folder") return `folder:${doc.id}`;
|
2026-06-23 18:30:22 +02:00
|
|
|
if (kind === "thread") return `thread:${doc.id}`;
|
2026-05-26 21:52:04 +05:30
|
|
|
if (kind === "connector") return `connector:${doc.connector_type ?? "UNKNOWN"}:${doc.id}`;
|
|
|
|
|
return `doc:${doc.document_type ?? "UNKNOWN"}:${doc.id}`;
|
2026-04-29 04:12:42 +05:30
|
|
|
}
|