feat(characters): support character-scoped conversations
This commit is contained in:
@@ -9,12 +9,14 @@ import { getLatestSplashMessagePreview } from "@/lib/chat/splash_latest_message_
|
||||
import { useSplashLatestMessageCache } from "@/providers/splash-latest-message-provider";
|
||||
|
||||
export interface UseSplashLatestMessageSyncInput {
|
||||
characterId: string;
|
||||
historyLoaded: boolean;
|
||||
loginStatus: LoginStatus;
|
||||
messages: readonly UiMessage[];
|
||||
}
|
||||
|
||||
export function useSplashLatestMessageSync({
|
||||
characterId,
|
||||
historyLoaded,
|
||||
loginStatus,
|
||||
messages,
|
||||
@@ -26,7 +28,7 @@ export function useSplashLatestMessageSync({
|
||||
useEffect(() => {
|
||||
hasObservedInitialSnapshotRef.current = false;
|
||||
identityPromiseRef.current = null;
|
||||
}, [loginStatus]);
|
||||
}, [characterId, loginStatus]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!historyLoaded) return;
|
||||
@@ -39,7 +41,8 @@ export function useSplashLatestMessageSync({
|
||||
const preview = getLatestSplashMessagePreview(messages);
|
||||
let cancelled = false;
|
||||
|
||||
identityPromiseRef.current ??= resolveSplashLatestMessageCacheIdentity();
|
||||
identityPromiseRef.current ??=
|
||||
resolveSplashLatestMessageCacheIdentity(characterId);
|
||||
void identityPromiseRef.current.then((identity) => {
|
||||
if (!cancelled && identity) {
|
||||
cache.set(identity, preview);
|
||||
@@ -49,5 +52,5 @@ export function useSplashLatestMessageSync({
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [cache, historyLoaded, messages]);
|
||||
}, [cache, characterId, historyLoaded, messages]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user