refactor: Unify document selection and drag interactions by replacing stack-specific callbacks and simplifying drag state.
This commit is contained in:
@@ -123,8 +123,8 @@ interface UseDocumentMutationsArgs {
|
||||
selectionAnchorRef: MutableRefObject<string | null>;
|
||||
setFocusedDocumentId: Dispatch<SetStateAction<DocumentId | null>>;
|
||||
focusedDocumentId: DocumentId | null;
|
||||
setFocusedRowKey: Dispatch<SetStateAction<string | null>>;
|
||||
focusedRowKey: string | null;
|
||||
setFocusedEntryKey: Dispatch<SetStateAction<string | null>>;
|
||||
focusedEntryKey: string | null;
|
||||
notifyApiError: NotifyApiError;
|
||||
setStatusMessage: SetStatusMessage;
|
||||
mapDocumentCaches: MapDocumentCaches;
|
||||
@@ -197,8 +197,8 @@ const useDocumentMutations = ({
|
||||
selectionAnchorRef,
|
||||
setFocusedDocumentId,
|
||||
focusedDocumentId,
|
||||
setFocusedRowKey,
|
||||
focusedRowKey,
|
||||
setFocusedEntryKey,
|
||||
focusedEntryKey,
|
||||
notifyApiError,
|
||||
setStatusMessage,
|
||||
mapDocumentCaches,
|
||||
@@ -357,11 +357,11 @@ const useDocumentMutations = ({
|
||||
setFocusedDocumentId(null);
|
||||
}
|
||||
if (
|
||||
focusedRowKey &&
|
||||
isDocumentEntry(focusedRowKey) &&
|
||||
uniqueIdSet.has(getEntryId(focusedRowKey) as DocumentId)
|
||||
focusedEntryKey &&
|
||||
isDocumentEntry(focusedEntryKey) &&
|
||||
uniqueIdSet.has(getEntryId(focusedEntryKey) as DocumentId)
|
||||
) {
|
||||
setFocusedRowKey(null);
|
||||
setFocusedEntryKey(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,8 +387,8 @@ const useDocumentMutations = ({
|
||||
selectionAnchorRef,
|
||||
setFocusedDocumentId,
|
||||
focusedDocumentId,
|
||||
setFocusedRowKey,
|
||||
focusedRowKey,
|
||||
setFocusedEntryKey,
|
||||
focusedEntryKey,
|
||||
notifyApiError,
|
||||
setStatusMessage,
|
||||
mapDocumentCaches,
|
||||
|
||||
@@ -259,8 +259,8 @@ const useDocumentsWorkspace = ({
|
||||
selectionInitializedRef,
|
||||
focusedDocumentId,
|
||||
setFocusedDocumentId,
|
||||
focusedRowKey,
|
||||
setFocusedRowKey,
|
||||
focusedEntryKey,
|
||||
setFocusedEntryKey,
|
||||
applySelection,
|
||||
handleEntrySelection,
|
||||
clearSelection,
|
||||
@@ -416,14 +416,14 @@ const useDocumentsWorkspace = ({
|
||||
[showingSearchResults, currentSubfolders],
|
||||
);
|
||||
|
||||
const visibleRowKeys = useMemo(
|
||||
const visibleEntryKeys = useMemo(
|
||||
() => [...visibleFolderKeys, ...visibleDocumentKeys],
|
||||
[visibleFolderKeys, visibleDocumentKeys],
|
||||
);
|
||||
|
||||
const visibleRowKeySet = useMemo(
|
||||
() => new Set(visibleRowKeys),
|
||||
[visibleRowKeys],
|
||||
const visibleEntryKeySet = useMemo(
|
||||
() => new Set(visibleEntryKeys),
|
||||
[visibleEntryKeys],
|
||||
);
|
||||
|
||||
const {
|
||||
@@ -750,8 +750,8 @@ const useDocumentsWorkspace = ({
|
||||
selectionAnchorRef,
|
||||
setFocusedDocumentId,
|
||||
focusedDocumentId,
|
||||
setFocusedRowKey,
|
||||
focusedRowKey,
|
||||
setFocusedEntryKey,
|
||||
focusedEntryKey,
|
||||
notifyApiError,
|
||||
setStatusMessage,
|
||||
mapDocumentCaches,
|
||||
@@ -812,7 +812,7 @@ const useDocumentsWorkspace = ({
|
||||
currentSubfolders,
|
||||
visibleDocuments: viewDocuments,
|
||||
configureSelectionEnvironment,
|
||||
visibleRowKeySet,
|
||||
visibleEntryKeySet,
|
||||
selectedEntries,
|
||||
selectionAnchorRef,
|
||||
promoteSelectionOrderRaw,
|
||||
@@ -820,8 +820,8 @@ const useDocumentsWorkspace = ({
|
||||
setActivePreviewId,
|
||||
clearSelection,
|
||||
focusedDocumentId,
|
||||
setFocusedRowKey,
|
||||
focusedRowKey,
|
||||
setFocusedEntryKey,
|
||||
focusedEntryKey,
|
||||
});
|
||||
const initializeAfterLogin = useCallback(async () => {
|
||||
await Promise.all([refreshTags(), refreshCorrespondents()]);
|
||||
|
||||
Reference in New Issue
Block a user