perf(offline): parallelise note caching with batched writes
Fetch blobs with a concurrency of 8 instead of one at a time, batch PouchDB writes via bulkUpdate, filter already-cached files up front, and run the README fetch in parallel with the worker loop.
This commit is contained in:
17
src/modules/note/cache/prepareNoteCache.ts
vendored
17
src/modules/note/cache/prepareNoteCache.ts
vendored
@@ -11,6 +11,23 @@ type NoteCacheResult =
|
||||
| { note: Note; from: "path" }
|
||||
| { note: null; from: null }
|
||||
|
||||
export const buildNoteDocs = (
|
||||
sha: string,
|
||||
path: string | undefined,
|
||||
content: string,
|
||||
editedSha?: string
|
||||
): Note[] => {
|
||||
const base: Note = {
|
||||
_id: generateId(DataType.Note, sha),
|
||||
$type: DataType.Note,
|
||||
content,
|
||||
editedSha
|
||||
}
|
||||
return path
|
||||
? [base, { ...base, _id: generateId(DataType.Note, path) }]
|
||||
: [base]
|
||||
}
|
||||
|
||||
export const prepareNoteCache = (sha: string, path?: string) => {
|
||||
const store = useUserRepoStore()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user