feat: Add an Ollama-based PDF OCR script and refactor frontend folder tree management with a new FoldersManager and useSyncExternalStore.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { getFolderTree, listFolderContents } from '../../../lib/api/apiClient';
|
||||
import type { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
||||
import { createRootNode, DEFAULT_FOLDER_NAME } from '../../../app/workspaceUtils';
|
||||
import { createRootNode, DEFAULT_FOLDER_NAME, flattenFolderTree } from '../../../app/workspaceUtils';
|
||||
import {
|
||||
getEntryId,
|
||||
isDocumentEntry,
|
||||
@@ -76,10 +76,13 @@ const useFolderTree = ({
|
||||
const next = new Map(prev);
|
||||
const rootChildren: FolderNodeId[] = [];
|
||||
|
||||
data.forEach((item) => {
|
||||
const flatData = flattenFolderTree(data);
|
||||
|
||||
flatData.forEach((item) => {
|
||||
const id = item.id as FolderNodeId;
|
||||
const parentId = (item.parent_id || 'root') as FolderNodeId;
|
||||
const children = (item.children || []).map((c) => c as FolderNodeId);
|
||||
// item.children is now FolderTreeNode[], so map to IDs
|
||||
const children = (item.children || []).map((c) => c.id as FolderNodeId);
|
||||
|
||||
next.set(id, {
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user