feat(nbstore): add indexer storage (#10953)

This commit is contained in:
EYHN
2025-03-31 12:59:51 +00:00
parent c9e14ac0db
commit 8957d0645f
82 changed files with 3393 additions and 4753 deletions
@@ -10,6 +10,7 @@ import { GlobalContextService } from '@affine/core/modules/global-context';
import { useI18n } from '@affine/i18n';
import {
LiveData,
MANUALLY_STOP,
useLiveData,
useService,
useServices,
@@ -78,19 +79,23 @@ export const ExplorerDocNode = ({
)
);
const indexerLoading = useLiveData(
docsSearchService.indexer.status$.map(
v => v.remaining === undefined || v.remaining > 0
)
);
const [referencesLoading, setReferencesLoading] = useState(true);
useLayoutEffect(() => {
setReferencesLoading(
prev =>
prev &&
indexerLoading /* after loading becomes false, it never becomes true */
);
}, [indexerLoading]);
const abortController = new AbortController();
docsSearchService.indexer
.waitForDocCompletedWithPriority(docId, 100, abortController.signal)
.then(() => {
setReferencesLoading(false);
})
.catch(err => {
if (err !== MANUALLY_STOP) {
console.error(err);
}
});
return () => {
abortController.abort(MANUALLY_STOP);
};
}, [docId, docsSearchService]);
const workspaceDialogService = useService(WorkspaceDialogService);
const option = useMemo(