1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-11 02:16:23 +00:00

move handleDelete outside of onClick react component

This commit is contained in:
Wolfie 2024-03-14 22:56:13 -04:00
parent 0cd01a54a0
commit 230630fb99
No known key found for this signature in database
GPG key ID: DE384EE9BF2D909A
2 changed files with 10 additions and 9 deletions

View file

@ -69,6 +69,7 @@ export const NoteModal = (props: ModalProps & { onClose: () => void; }) => {
const notes = noteHandler.getNotes(currentNotebook);
if (!notes) return <></>;
const { TabBar, selectedTab } = CreateTabBar({ tabs: noteHandler.getAllNotes(), firstSelectedTab: currentNotebook, onChangeTab: setCurrentNotebook });
return (

View file

@ -15,7 +15,10 @@ import { RenderMessage } from "./RenderMessage";
export default ({ onClose, notebook, ...props }: ModalProps & { onClose: () => void; notebook: string; }) => {
const notes = noteHandler.getNotes(notebook);
if (!notes) return <></>;
const handleDelete = () => {
onClose();
noteHandler.deleteNotebook(notebook);
};
return (
<ModalRoot
@ -28,25 +31,22 @@ export default ({ onClose, notebook, ...props }: ModalProps & { onClose: () => v
</ModalHeader>
<ModalContent>
<ErrorBoundary>
{Object.keys(notes).length === 0 || !notes ? (
<Error />
) : (
{notes && Object.keys(notes).length > 0 ? (
Object.values(notes).map(note => (
<RenderMessage
note={note}
notebook={notebook}
fromDeleteModal={true} />
))
) : (
<Error />
)}
</ErrorBoundary>
</ModalContent>
<ModalFooter>
<Button
color={Button.Colors.RED}
onClick={() => {
noteHandler.deleteNotebook(notebook);
onClose();
}}
onClick={handleDelete}
>
DELETE
</Button>