mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
feat: improve public chat UI and shared components
This commit is contained in:
parent
37adc54d6a
commit
ee65e1377f
14 changed files with 403 additions and 275 deletions
28
surfsense_web/atoms/chat/chat-thread-mutation.atoms.ts
Normal file
28
surfsense_web/atoms/chat/chat-thread-mutation.atoms.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { atomWithMutation } from "jotai-tanstack-query";
|
||||
import { toast } from "sonner";
|
||||
import type {
|
||||
TogglePublicShareRequest,
|
||||
TogglePublicShareResponse,
|
||||
} from "@/contracts/types/chat-threads.types";
|
||||
import { chatThreadsApiService } from "@/lib/apis/chat-threads-api.service";
|
||||
|
||||
export const togglePublicShareMutationAtom = atomWithMutation(() => ({
|
||||
mutationFn: async (request: TogglePublicShareRequest) => {
|
||||
return chatThreadsApiService.togglePublicShare(request);
|
||||
},
|
||||
onSuccess: (response: TogglePublicShareResponse) => {
|
||||
if (response.enabled && response.share_token) {
|
||||
const publicUrl = `${window.location.origin}/public/${response.share_token}`;
|
||||
navigator.clipboard.writeText(publicUrl);
|
||||
toast.success("Public link copied to clipboard", {
|
||||
description: "Anyone with this link can view the chat",
|
||||
});
|
||||
} else {
|
||||
toast.success("Public sharing disabled");
|
||||
}
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
console.error("Failed to toggle public share:", error);
|
||||
toast.error("Failed to update public sharing");
|
||||
},
|
||||
}));
|
||||
Loading…
Add table
Add a link
Reference in a new issue