feat(frontend): two-phase cloning with loading state

This commit is contained in:
CREDO23 2026-01-28 00:17:44 +02:00
parent 0c8d1f3fef
commit 9a4da10b12
5 changed files with 85 additions and 13 deletions

View file

@ -22,22 +22,15 @@ export function PublicChatFooter({ shareToken }: PublicChatFooterProps) {
setIsCloning(true);
try {
await publicChatApiService.clonePublicChat({
const response = await publicChatApiService.clonePublicChat({
share_token: shareToken,
});
// Force PGlite to resync notifications on next dashboard load
localStorage.setItem("surfsense_force_notif_resync", "true");
toast.success("Copying chat to your account...", {
description: "You'll be notified when it's ready.",
});
router.push("/dashboard");
// Redirect to the new chat page (content will be loaded there)
router.push(`/dashboard/${response.search_space_id}/new-chat/${response.thread_id}`);
} catch (error) {
const message = error instanceof Error ? error.message : "Failed to copy chat";
toast.error(message);
} finally {
setIsCloning(false);
}
}, [shareToken, router]);