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:
parent
0cd01a54a0
commit
230630fb99
2 changed files with 10 additions and 9 deletions
|
@ -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 (
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue