perf: move PouchDB/IndexedDB operations to a Web Worker
All database reads and writes now run off the main thread via a dedicated worker, eliminating IndexedDB overhead from the frame budget. - Create data.worker.ts exposing the Data class via Comlink - Refactor data.ts to export a Comlink-wrapped proxy and a standalone generateId() pure function (workers can't expose sync methods cleanly) - Update all 10 call sites to import generateId directly instead of calling data.generateId() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
6
src/modules/note/cache/prepareNoteCache.ts
vendored
6
src/modules/note/cache/prepareNoteCache.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { data } from "@/data/data"
|
||||
import { data, generateId } from "@/data/data"
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { Note } from "@/modules/note/models/Note"
|
||||
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
|
||||
@@ -14,8 +14,8 @@ type NoteCacheResult =
|
||||
export const prepareNoteCache = (sha: string, path?: string) => {
|
||||
const store = useUserRepoStore()
|
||||
|
||||
const noteId = data.generateId(DataType.Note, sha)
|
||||
const notePath = path ? data.generateId(DataType.Note, path) : null
|
||||
const noteId = generateId(DataType.Note, sha)
|
||||
const notePath = path ? generateId(DataType.Note, path) : null
|
||||
const getCachedNote = async (): Promise<NoteCacheResult> => {
|
||||
const note = await data.get<DataType.Note, Note>(noteId)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user