fix(settings): delete button

This commit is contained in:
ManishMadan2882
2024-02-09 18:04:24 +05:30
parent 18be257e10
commit c0ed54406f

View File

@@ -8,10 +8,10 @@ import {
selectPrompt, selectPrompt,
setPrompt, setPrompt,
selectSourceDocs, selectSourceDocs,
setSourceDocs,
} from './preferences/preferenceSlice'; } from './preferences/preferenceSlice';
import { Doc } from './preferences/preferenceApi'; import { Doc } from './preferences/preferenceApi';
import { useDarkTheme } from './hooks'; import { useDarkTheme } from './hooks';
import { Light } from 'react-syntax-highlighter';
type PromptProps = { type PromptProps = {
prompts: { name: string; id: string; type: string }[]; prompts: { name: string; id: string; type: string }[];
selectedPrompt: { name: string; id: string; type: string }; selectedPrompt: { name: string; id: string; type: string };
@@ -86,13 +86,11 @@ const Setting: React.FC = () => {
fetch(`${apiHost}/api/delete_old?path=${docPath}`, { fetch(`${apiHost}/api/delete_old?path=${docPath}`, {
method: 'GET', method: 'GET',
}) })
.then(() => { .then((response) => {
// remove the image element from the DOM if(response.ok && documents){
const imageElement = document.querySelector( const updatedDocuments = [...documents.slice(0, index), ...documents.slice(index + 1)];
`#img-${index}`, dispatch(setSourceDocs(updatedDocuments));
) as HTMLElement; }
const parentElement = imageElement.parentNode as HTMLElement;
parentElement.parentNode?.removeChild(parentElement);
}) })
.catch((error) => console.error(error)); .catch((error) => console.error(error));
}; };