From 9ac18e787f91f5b94c429275acd6f7d376d1a2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 25 Oct 2022 00:01:53 +0200 Subject: [PATCH] Show unauthorized modal when clicking emoji button if unauthorized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../components/emoji-button-wrapper.tsx | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/soapbox/components/emoji-button-wrapper.tsx b/app/soapbox/components/emoji-button-wrapper.tsx index 0afdba85f..d85d22627 100644 --- a/app/soapbox/components/emoji-button-wrapper.tsx +++ b/app/soapbox/components/emoji-button-wrapper.tsx @@ -83,10 +83,7 @@ const EmojiButtonWrapper: React.FC = ({ statusId, children if (ownAccount) { dispatch(simpleEmojiReact(status, emoji)); } else { - dispatch(openModal('UNAUTHORIZED', { - action: 'FAVOURITE', - ap_id: status.url, - })); + handleUnauthorized(); } setVisible(false); @@ -96,10 +93,14 @@ const EmojiButtonWrapper: React.FC = ({ statusId, children const meEmojiReact = getReactForStatus(status, soapboxConfig.allowedEmoji) || '👍'; if (isUserTouching()) { - if (visible) { - handleReact(meEmojiReact); + if (ownAccount) { + if (visible) { + handleReact(meEmojiReact); + } else { + setVisible(true); + } } else { - setVisible(true); + handleUnauthorized(); } } else { handleReact(meEmojiReact); @@ -109,6 +110,13 @@ const EmojiButtonWrapper: React.FC = ({ statusId, children e.stopPropagation(); }; + const handleUnauthorized = () => { + dispatch(openModal('UNAUTHORIZED', { + action: 'FAVOURITE', + ap_id: status.url, + })); + }; + // const handleUnfocus: React.EventHandler = () => { // setFocused(false); // };