refactor(chat): remove guest history synchronization

This commit is contained in:
2026-07-20 14:02:39 +08:00
parent 1f7ab2be04
commit 4d1c85727a
17 changed files with 10 additions and 300 deletions
+2 -22
View File
@@ -16,11 +16,6 @@ import {
useAuthSelector,
} from "@/stores/auth/auth-context";
import { useChatDispatch } from "@/stores/chat/chat-context";
import { syncGuestHistoriesToUser } from "@/stores/chat/guest-history-sync";
import { useCharacterCatalog } from "@/providers/character-catalog-provider";
import { resolveChatCacheOwnerKey } from "@/data/repositories/chat_cache_identity";
import { NavigationStorage } from "@/data/storage/navigation";
import { Result } from "@/utils/result";
export function ChatAuthSync() {
const authState = useAuthSelector(
@@ -32,7 +27,6 @@ export function ChatAuthSync() {
shallowEqual,
);
const chatDispatch = useChatDispatch();
const characterCatalog = useCharacterCatalog();
const prevSessionKeyRef = useRef<string | null>(null);
useEffect(() => {
@@ -48,27 +42,14 @@ export function ChatAuthSync() {
}
if (authState.loginStatus === "guest") {
let cancelled = false;
void (async () => {
const ownerResult = await resolveChatCacheOwnerKey();
if (Result.isOk(ownerResult)) {
await NavigationStorage.saveGuestChatOwnerKey(ownerResult.data);
}
if (!cancelled) chatDispatch({ type: "ChatGuestLogin" });
})();
return () => {
cancelled = true;
};
chatDispatch({ type: "ChatGuestLogin" });
return;
}
let cancelled = false;
void (async () => {
const tokenR = await AuthStorage.getInstance().getLoginToken();
if (!cancelled && tokenR.success && tokenR.data) {
await syncGuestHistoriesToUser(
characterCatalog.characters.map((character) => character.id),
);
if (cancelled) return;
chatDispatch({
type: "ChatUserLogin",
token: tokenR.data,
@@ -83,7 +64,6 @@ export function ChatAuthSync() {
authState.hasInitialized,
authState.isLoading,
authState.loginStatus,
characterCatalog.characters,
chatDispatch,
]);