cleanup
This commit is contained in:
@@ -51,7 +51,7 @@ import useDetailWorkspace from '../../viewer/logic/useDetailWorkspace';
|
||||
import useWorkspaceTaxonomies from './useWorkspaceTaxonomies';
|
||||
import useWorkspaceBreadcrumbs from '../logic/useWorkspaceBreadcrumbs';
|
||||
import useWorkspaceSelectionSync from '../features/selection/useWorkspaceSelectionSync';
|
||||
import type { DocumentId, FolderId as FolderIdentifier, Identifier } from '../../types/identifiers';
|
||||
import type { DocumentId, FolderNodeId, Identifier } from '../../types/identifiers';
|
||||
|
||||
const EntryType = Object.freeze({
|
||||
document: 'document',
|
||||
@@ -60,14 +60,13 @@ const EntryType = Object.freeze({
|
||||
|
||||
const noop = () => { };
|
||||
|
||||
type FolderId = FolderIdentifier | 'root';
|
||||
|
||||
import type { Document } from '../../types/documents';
|
||||
|
||||
interface FolderContentsEntry {
|
||||
folder?: { id?: FolderId; name?: string | null } | null;
|
||||
folder?: { id?: FolderNodeId; name?: string | null } | null;
|
||||
documents?: Document[];
|
||||
subfolders?: Array<{ id?: FolderId; name?: string | null;[key: string]: unknown }>;
|
||||
subfolders?: Array<{ id?: FolderNodeId; name?: string | null;[key: string]: unknown }>;
|
||||
__includesDocuments?: boolean;
|
||||
__sortField?: string | null;
|
||||
__sortDirection?: string | null;
|
||||
@@ -210,7 +209,7 @@ const useDocumentsWorkspace = ({
|
||||
);
|
||||
|
||||
const [draggedDocumentIds, setDraggedDocumentIds] = useState<DocumentId[]>([]);
|
||||
const [draggedFolderId, setDraggedFolderId] = useState<FolderId | null>(null);
|
||||
const [draggedFolderId, setDraggedFolderId] = useState<FolderNodeId | null>(null);
|
||||
const [activePreviewId, setActivePreviewId] = useState<DocumentId | null>(routeDocumentId || null);
|
||||
const shellRef = useRef(null);
|
||||
const assetManagerRef = useRef(null);
|
||||
@@ -293,7 +292,7 @@ const useDocumentsWorkspace = ({
|
||||
],
|
||||
);
|
||||
|
||||
const [folderContents, setFolderContents] = useState<Map<FolderId, FolderContentsEntry>>(
|
||||
const [folderContents, setFolderContents] = useState<Map<FolderNodeId, FolderContentsEntry>>(
|
||||
() => new Map(),
|
||||
);
|
||||
const folderContentsRef = useRef(folderContents);
|
||||
@@ -687,12 +686,12 @@ const useDocumentsWorkspace = ({
|
||||
return filtered.length === prev.length ? prev : filtered;
|
||||
});
|
||||
|
||||
setFolderContents((prev: Map<FolderId, FolderContentsEntry>) => {
|
||||
setFolderContents((prev: Map<FolderNodeId, FolderContentsEntry>) => {
|
||||
if (!prev.size) {
|
||||
return prev;
|
||||
}
|
||||
let changed = false;
|
||||
const next = new Map<FolderId, FolderContentsEntry>();
|
||||
const next = new Map<FolderNodeId, FolderContentsEntry>();
|
||||
prev.forEach((contents, key) => {
|
||||
const docs = Array.isArray(contents?.documents) ? contents.documents : null;
|
||||
if (!docs || docs.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user