mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
18 lines
582 B
TypeScript
18 lines
582 B
TypeScript
type MentionKeyInput = {
|
|
id: number;
|
|
document_type?: string | null;
|
|
kind?: "doc" | "folder" | "connector";
|
|
};
|
|
|
|
/**
|
|
* 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).
|
|
*/
|
|
export function getMentionDocKey(doc: MentionKeyInput): string {
|
|
const kind = doc.kind ?? "doc";
|
|
return `${kind}:${doc.document_type ?? "UNKNOWN"}:${doc.id}`;
|
|
}
|