perf(client): defer chat persistence dependencies

This commit is contained in:
2026-07-15 17:58:06 +08:00
parent 86ffbbcdbc
commit 05ca15be48
15 changed files with 115 additions and 81 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
import { fromPromise } from "xstate";
import { getChatRepository } from "@/data/repositories/chat_repository";
import { loadChatRepository } from "@/data/repositories/chat_repository_loader";
import { resolveChatCacheOwnerKey } from "@/data/repositories/chat_cache_identity";
import { Logger } from "@/utils/logger";
import { Result } from "@/utils/result";
@@ -23,7 +23,7 @@ export interface UnlockHistoryOutput {
}
export const unlockHistoryActor = fromPromise<UnlockHistoryOutput>(async () => {
const chatRepo = getChatRepository();
const chatRepo = await loadChatRepository();
const unlockResult = await chatRepo.unlockHistory();
if (Result.isErr(unlockResult)) {
log.error("[chat-machine] unlockHistoryActor failed", {
@@ -45,7 +45,7 @@ export const unlockMessageActor = fromPromise<
UnlockMessageOutput,
UnlockMessageRequest
>(async ({ input }) => {
const chatRepo = getChatRepository();
const chatRepo = await loadChatRepository();
const cacheIdentityResult = await resolveChatCacheOwnerKey();
const unlockResult = await chatRepo.unlockPrivateMessage({
...(input.messageId ? { messageId: input.messageId } : {}),