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:
@@ -4,7 +4,7 @@ import { useAsyncState } from "@vueuse/core"
|
||||
import { addDays, isAfter } from "date-fns"
|
||||
import { computed, nextTick, watch } from "vue"
|
||||
|
||||
import { data } from "@/data/data"
|
||||
import { data, generateId } from "@/data/data"
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { useFile } from "@/hooks/useFile.hook"
|
||||
import { useLinks } from "@/hooks/useLinks.hook"
|
||||
@@ -51,7 +51,7 @@ export const useSpacedRepetitionCards = () => {
|
||||
const repetition = await data.getOrCreate<
|
||||
DataType.RepetitionCard,
|
||||
RepetitionCard
|
||||
>(data.generateId(DataType.RepetitionCard, cardFile.path), {
|
||||
>(generateId(DataType.RepetitionCard, cardFile.path), {
|
||||
$type: DataType.RepetitionCard,
|
||||
level: 1,
|
||||
repeatDate: new Date(),
|
||||
|
||||
Reference in New Issue
Block a user