fix(web): conversation DELETE — resolve Failed to fetch TypeError (#204)
Some checks failed
ci/woodpecker/push/ci Pipeline failed
Some checks failed
ci/woodpecker/push/ci Pipeline failed
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #204.
This commit is contained in:
@@ -40,6 +40,7 @@ async function bootstrap(): Promise<void> {
|
|||||||
app.enableCors({
|
app.enableCors({
|
||||||
origin: process.env['GATEWAY_CORS_ORIGIN'] ?? 'http://localhost:3000',
|
origin: process.env['GATEWAY_CORS_ORIGIN'] ?? 'http://localhost:3000',
|
||||||
credentials: true,
|
credentials: true,
|
||||||
|
methods: ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
|
||||||
});
|
});
|
||||||
|
|
||||||
await app.register(helmet as never, { contentSecurityPolicy: false });
|
await app.register(helmet as never, { contentSecurityPolicy: false });
|
||||||
|
|||||||
@@ -151,11 +151,15 @@ export default function ChatPage(): React.ReactElement {
|
|||||||
|
|
||||||
const handleDelete = useCallback(
|
const handleDelete = useCallback(
|
||||||
async (id: string) => {
|
async (id: string) => {
|
||||||
await api<void>(`/api/conversations/${id}`, { method: 'DELETE' });
|
try {
|
||||||
setConversations((prev) => prev.filter((c) => c.id !== id));
|
await api<void>(`/api/conversations/${id}`, { method: 'DELETE' });
|
||||||
if (activeId === id) {
|
setConversations((prev) => prev.filter((c) => c.id !== id));
|
||||||
setActiveId(null);
|
if (activeId === id) {
|
||||||
setMessages([]);
|
setActiveId(null);
|
||||||
|
setMessages([]);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[ChatPage] Failed to delete conversation:', err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[activeId],
|
[activeId],
|
||||||
|
|||||||
Reference in New Issue
Block a user