feat: Refactor tag drag and drop interactions

This commit is contained in:
2025-11-27 17:59:28 +01:00
parent 68ed888172
commit 9bf9550b03
14 changed files with 380 additions and 196 deletions
@@ -937,32 +937,16 @@ const useDocumentsWorkspace = ({
);
const handleDocumentTagDrop = useCallback(
async (documentId, tag) => {
if (!documentId || !tag?.id) {
async (documentId, tagId) => {
if (!documentId || !tagId) {
return;
}
if (tag.sourceDocId && tag.sourceDocId === documentId) {
return;
}
const attached = await handleDocumentTagAttach({ documentId, tagId: tag.id, tag });
if (!attached) {
return;
}
if (tag.sourceDocId && tag.sourceDocId !== documentId) {
await handleTagRemove(tag.sourceDocId, tag.id, {
refreshTagList: false,
showMessage: false,
});
}
await handleDocumentTagAttach({ documentId, tagId });
},
[handleDocumentTagAttach, handleTagRemove],
[handleDocumentTagAttach],
);
const handlePromptCreateFolder = useCallback(async (parentId?: Identifier | null) => {
if (creatingFolder) {
return;
@@ -1214,7 +1198,8 @@ const useDocumentsWorkspace = ({
activeCorrespondentFilters,
ensureAssetUrl,
getDocumentAsset,
handleDocumentTagDrop,
handleDocumentTagAttach: handleDocumentTagDrop,
handleDocumentTagDetach: handleTagRemove,
documentsViewMode,
documentsSortField,
documentsSortDirection,