From 1533d450007de6b3c7a26fe42659faabfb9847ea Mon Sep 17 00:00:00 2001 From: Bojan Mojsilovic Date: Mon, 18 Mar 2024 15:59:56 +0100 Subject: [PATCH] Fix custom zap opening from context --- src/components/Note/NoteContextMenu.tsx | 6 ++---- src/contexts/AppContext.tsx | 11 ++++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/Note/NoteContextMenu.tsx b/src/components/Note/NoteContextMenu.tsx index 6afa326..e517a58 100644 --- a/src/components/Note/NoteContextMenu.tsx +++ b/src/components/Note/NoteContextMenu.tsx @@ -45,8 +45,6 @@ const NoteContextMenu: Component<{ const position = () => { return props.data?.position; }; - const openCustomZap = props.data?.openCustomZap || (() => {}); - const openReactions = props.data?.openReactions || (() => {}); createEffect(() => { if(!context) return; @@ -163,7 +161,7 @@ const NoteContextMenu: Component<{ { label: intl.formatMessage(tActions.noteContext.reactions), action: () => { - openReactions(); + props.data?.openReactions && props.data?.openReactions(); props.onClose() }, icon: 'heart', @@ -171,7 +169,7 @@ const NoteContextMenu: Component<{ { label: intl.formatMessage(tActions.noteContext.zap), action: () => { - openCustomZap(); + props.data?.openCustomZap && props.data?.openCustomZap(); props.onClose() }, icon: 'feed_zap', diff --git a/src/contexts/AppContext.tsx b/src/contexts/AppContext.tsx index 3516eb3..a99b28e 100644 --- a/src/contexts/AppContext.tsx +++ b/src/contexts/AppContext.tsx @@ -109,12 +109,17 @@ export const AppProvider = (props: { children: JSXElement }) => { updateStore('showCustomZapModal', () => false); }; - const openContextMenu = (note: PrimalNote, position: DOMRect | undefined, openCustomZapModal: () => void, openReactionModal: () => void) => { + const openContextMenu = ( + note: PrimalNote, + position: DOMRect | undefined, + openCustomZap: () => void, + openReactions: () => void, + ) => { updateStore('noteContextMenuInfo', reconcile({ note, position, - openCustomZapModal, - openReactionModal, + openCustomZap, + openReactions, })) updateStore('showNoteContextMenu', () => true); };