mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
fix(settings): delete button
This commit is contained in:
@@ -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));
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user