mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-30 09:03:15 +00:00
added support for multi select sources
This commit is contained in:
@@ -149,9 +149,10 @@ export default function SourcesPopup({
|
||||
if (option.model === embeddingsName) {
|
||||
const isSelected =
|
||||
selectedDocs &&
|
||||
(option.id
|
||||
? selectedDocs.id === option.id
|
||||
: selectedDocs.date === option.date);
|
||||
Array.isArray(selectedDocs) && selectedDocs.length > 0 &&
|
||||
selectedDocs.some(doc =>
|
||||
option.id ? doc.id === option.id : doc.date === option.date
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -159,11 +160,19 @@ export default function SourcesPopup({
|
||||
className="border-opacity-80 dark:border-dim-gray flex cursor-pointer items-center border-b border-[#D9D9D9] p-3 transition-colors hover:bg-gray-100 dark:text-[14px] dark:hover:bg-[#2C2E3C]"
|
||||
onClick={() => {
|
||||
if (isSelected) {
|
||||
dispatch(setSelectedDocs(null));
|
||||
handlePostDocumentSelect(null);
|
||||
const updatedDocs = (selectedDocs && Array.isArray(selectedDocs))
|
||||
? selectedDocs.filter(doc =>
|
||||
option.id ? doc.id !== option.id : doc.date !== option.date
|
||||
)
|
||||
: [];
|
||||
dispatch(setSelectedDocs(updatedDocs.length > 0 ? updatedDocs : null));
|
||||
handlePostDocumentSelect(updatedDocs.length > 0 ? updatedDocs : null);
|
||||
} else {
|
||||
dispatch(setSelectedDocs(option));
|
||||
handlePostDocumentSelect(option);
|
||||
const updatedDocs = (selectedDocs && Array.isArray(selectedDocs))
|
||||
? [...selectedDocs, option]
|
||||
: [option];
|
||||
dispatch(setSelectedDocs(updatedDocs));
|
||||
handlePostDocumentSelect(updatedDocs);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user