Fix clear sessione
This commit is contained in:
@@ -4,7 +4,7 @@ import "./App.css";
|
||||
import { themes } from "./themes";
|
||||
import ChatLayout from "./ChatLayout";
|
||||
import { useChatStream } from "./useChatStream";
|
||||
import { getSessionId, getUserId, resetSessionId, setSessionId } from "./useSessionId";
|
||||
import { getSessionId, getUserId, clearSessionId, setSessionId } from "./useSessionId";
|
||||
|
||||
export default function App() {
|
||||
const { messages, loading, sendMessage, stopGenerating, setMessages } = useChatStream();
|
||||
@@ -54,8 +54,8 @@ export default function App() {
|
||||
const freshStart = async () => {
|
||||
await fetch(`/v1/history?user_id=${userId}&session_id=${sessionId}`, { method: "DELETE" });
|
||||
setMessages([]);
|
||||
const newId = resetSessionId();
|
||||
setSessionId(newId);
|
||||
clearSessionId(); // <-- ora rimuove del tutto la sessione
|
||||
setSessionName("");
|
||||
};
|
||||
|
||||
const createSession = async () => {
|
||||
|
||||
@@ -13,24 +13,12 @@ export function getSessionId() {
|
||||
return localStorage.getItem("sessionId") || null;
|
||||
}
|
||||
|
||||
export function getSessionIdForced() {
|
||||
// Always re‑read localStorage so latest value is returned
|
||||
let id = localStorage.getItem("sessionId");
|
||||
if (!id) {
|
||||
id = crypto.randomUUID();
|
||||
localStorage.setItem("sessionId", id);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
export function setSessionId(id) {
|
||||
localStorage.setItem("sessionId", id);
|
||||
}
|
||||
|
||||
export function resetSessionId() {
|
||||
const newId = crypto.randomUUID();
|
||||
localStorage.setItem("sessionId", newId);
|
||||
return newId;
|
||||
export function clearSessionId() {
|
||||
localStorage.removeItem("sessionId");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user