mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-03 21:02:40 +02:00
refactor(mentions): replace sidebarSelectedDocumentsAtom with mentionedDocumentsAtom and introduce getMentionDocKey utility for consistent document key generation
This commit is contained in:
parent
282510f93c
commit
76c91adebc
5 changed files with 102 additions and 93 deletions
|
|
@ -9,29 +9,6 @@ import type { Document } from "@/contracts/types/document.types";
|
|||
*/
|
||||
export const mentionedDocumentsAtom = atom<Pick<Document, "id" | "title" | "document_type">[]>([]);
|
||||
|
||||
/**
|
||||
* Back-compat alias for sidebar checkbox selection.
|
||||
* This now points to mentionedDocumentsAtom so the app has a single source
|
||||
* of truth for mentioned/selected documents.
|
||||
*/
|
||||
export const sidebarSelectedDocumentsAtom = atom<
|
||||
Pick<Document, "id" | "title" | "document_type">[],
|
||||
[
|
||||
| Pick<Document, "id" | "title" | "document_type">[]
|
||||
| ((
|
||||
prev: Pick<Document, "id" | "title" | "document_type">[]
|
||||
) => Pick<Document, "id" | "title" | "document_type">[]),
|
||||
],
|
||||
void
|
||||
>(
|
||||
(get) => get(mentionedDocumentsAtom),
|
||||
(get, set, update) => {
|
||||
const prev = get(mentionedDocumentsAtom);
|
||||
const next = typeof update === "function" ? update(prev) : update;
|
||||
set(mentionedDocumentsAtom, next);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Derived read-only atom that maps deduplicated mentioned docs
|
||||
* into backend payload fields.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue