mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-11 10:26:21 +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);
|
const notes = noteHandler.getNotes(currentNotebook);
|
||||||
if (!notes) return <></>;
|
if (!notes) return <></>;
|
||||||
|
|
||||||
const { TabBar, selectedTab } = CreateTabBar({ tabs: noteHandler.getAllNotes(), firstSelectedTab: currentNotebook, onChangeTab: setCurrentNotebook });
|
const { TabBar, selectedTab } = CreateTabBar({ tabs: noteHandler.getAllNotes(), firstSelectedTab: currentNotebook, onChangeTab: setCurrentNotebook });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -15,7 +15,10 @@ import { RenderMessage } from "./RenderMessage";
|
||||||
export default ({ onClose, notebook, ...props }: ModalProps & { onClose: () => void; notebook: string; }) => {
|
export default ({ onClose, notebook, ...props }: ModalProps & { onClose: () => void; notebook: string; }) => {
|
||||||
const notes = noteHandler.getNotes(notebook);
|
const notes = noteHandler.getNotes(notebook);
|
||||||
|
|
||||||
if (!notes) return <></>;
|
const handleDelete = () => {
|
||||||
|
onClose();
|
||||||
|
noteHandler.deleteNotebook(notebook);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalRoot
|
<ModalRoot
|
||||||
|
@ -28,25 +31,22 @@ export default ({ onClose, notebook, ...props }: ModalProps & { onClose: () => v
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
{Object.keys(notes).length === 0 || !notes ? (
|
{notes && Object.keys(notes).length > 0 ? (
|
||||||
<Error />
|
|
||||||
) : (
|
|
||||||
Object.values(notes).map(note => (
|
Object.values(notes).map(note => (
|
||||||
<RenderMessage
|
<RenderMessage
|
||||||
note={note}
|
note={note}
|
||||||
notebook={notebook}
|
notebook={notebook}
|
||||||
fromDeleteModal={true} />
|
fromDeleteModal={true} />
|
||||||
))
|
))
|
||||||
|
) : (
|
||||||
|
<Error />
|
||||||
)}
|
)}
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button
|
<Button
|
||||||
color={Button.Colors.RED}
|
color={Button.Colors.RED}
|
||||||
onClick={() => {
|
onClick={handleDelete}
|
||||||
noteHandler.deleteNotebook(notebook);
|
|
||||||
onClose();
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
DELETE
|
DELETE
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Reference in a new issue