From 230630fb99e347cc975de05cd0baf2889133bec0 Mon Sep 17 00:00:00 2001 From: Wolfie <32025746+Wolfkid200444@users.noreply.github.com> Date: Thu, 14 Mar 2024 22:56:13 -0400 Subject: [PATCH] move handleDelete outside of onClick react component --- .../holynotes/components/modals/Notebook.tsx | 1 + .../components/modals/NotebookDeleteModal.tsx | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/plugins/holynotes/components/modals/Notebook.tsx b/src/plugins/holynotes/components/modals/Notebook.tsx index 5db29a5ed..2dae430cc 100644 --- a/src/plugins/holynotes/components/modals/Notebook.tsx +++ b/src/plugins/holynotes/components/modals/Notebook.tsx @@ -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 ( diff --git a/src/plugins/holynotes/components/modals/NotebookDeleteModal.tsx b/src/plugins/holynotes/components/modals/NotebookDeleteModal.tsx index 261bda316..30acda07b 100644 --- a/src/plugins/holynotes/components/modals/NotebookDeleteModal.tsx +++ b/src/plugins/holynotes/components/modals/NotebookDeleteModal.tsx @@ -5,7 +5,7 @@ */ import ErrorBoundary from "@components/ErrorBoundary"; -import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps,ModalRoot, ModalSize } from "@utils/modal"; +import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; import { Button, React, Text } from "@webpack/common"; import noteHandler from "plugins/holynotes/noteHandler"; @@ -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 ( v - {Object.keys(notes).length === 0 || !notes ? ( - - ) : ( + {notes && Object.keys(notes).length > 0 ? ( Object.values(notes).map(note => ( )) + ) : ( + )}