2026-04-29 04:12:42 +05:30
|
|
|
type MentionKeyInput = {
|
|
|
|
|
id: number;
|
|
|
|
|
document_type?: string | null;
|
2026-05-09 22:15:51 -07:00
|
|
|
kind?: "doc" | "folder";
|
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.
|
|
|
|
|
*
|
|
|
|
|
* The ``kind:document_type:id`` shape prevents a document and a folder
|
|
|
|
|
* with the same integer id from colliding in the chip array (folders
|
|
|
|
|
* use the ``FOLDER`` sentinel ``document_type``; the ``kind`` prefix
|
|
|
|
|
* is the belt-and-braces guard).
|
|
|
|
|
*/
|
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";
|
|
|
|
|
return `${kind}:${doc.document_type ?? "UNKNOWN"}:${doc.id}`;
|
2026-04-29 04:12:42 +05:30
|
|
|
}
|