mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Fix logic for deletion to automatically re-render the side pane
This commit is contained in:
parent
20d95dc45e
commit
998d08f155
1 changed files with 6 additions and 14 deletions
|
@ -4,6 +4,8 @@ import styles from "./sidePanel.module.css";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import { mutate } from "swr";
|
||||||
|
|
||||||
import { UserProfile, useAuthenticatedData } from "@/app/common/auth";
|
import { UserProfile, useAuthenticatedData } from "@/app/common/auth";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
@ -148,7 +150,10 @@ function deleteConversation(conversationId: string) {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => {
|
||||||
|
response.json();
|
||||||
|
mutate("/api/chat/sessions");
|
||||||
|
})
|
||||||
.then((data) => {})
|
.then((data) => {})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
@ -553,19 +558,6 @@ function ChatSessionActionMenu(props: ChatSessionActionMenuProps) {
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
deleteConversation(props.conversationId);
|
deleteConversation(props.conversationId);
|
||||||
setIsDeleting(false);
|
setIsDeleting(false);
|
||||||
var currConversationId = parseInt(
|
|
||||||
new URLSearchParams(window.location.search).get(
|
|
||||||
"conversationId",
|
|
||||||
) || "0",
|
|
||||||
);
|
|
||||||
//edge case for deleting current conversation
|
|
||||||
if (currConversationId === parseInt(props.conversationId)) {
|
|
||||||
window.location.href = "/";
|
|
||||||
}
|
|
||||||
//reload side panel
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, 1000);
|
|
||||||
}}
|
}}
|
||||||
className="bg-rose-500 hover:bg-rose-600"
|
className="bg-rose-500 hover:bg-rose-600"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue