From 87e950733f3c096d6ad42d76d540ebcdfb8f8955 Mon Sep 17 00:00:00 2001 From: "Kilu.He" <108015703+qinluhe@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:07:12 +0800 Subject: [PATCH] fix: react action bugs (#5851) --- .../global-comment/actions/ReactAction.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/appflowy_web_app/src/components/global-comment/actions/ReactAction.tsx b/frontend/appflowy_web_app/src/components/global-comment/actions/ReactAction.tsx index 6ab0ff412e..f0726926fc 100644 --- a/frontend/appflowy_web_app/src/components/global-comment/actions/ReactAction.tsx +++ b/frontend/appflowy_web_app/src/components/global-comment/actions/ReactAction.tsx @@ -3,15 +3,18 @@ import { EmojiPicker } from '@/components/_shared/emoji-picker'; import { EMOJI_SIZE, PER_ROW_EMOJI_COUNT } from '@/components/_shared/emoji-picker/const'; import { Popover } from '@/components/_shared/popover'; import ComponentLoading from '@/components/_shared/progress/ComponentLoading'; +import { AFConfigContext } from '@/components/app/AppConfig'; import { useGlobalCommentContext } from '@/components/global-comment/GlobalComment.hooks'; import { ReactComponent as AddReactionRounded } from '@/assets/add_reaction.svg'; import { IconButton, Tooltip } from '@mui/material'; -import React, { memo, Suspense, useCallback } from 'react'; +import React, { memo, Suspense, useCallback, useContext } from 'react'; import { useTranslation } from 'react-i18next'; function ReactAction({ comment }: { comment: GlobalComment }) { const { toggleReaction } = useGlobalCommentContext(); const { t } = useTranslation(); + const isAuthenticated = useContext(AFConfigContext)?.isAuthenticated || false; + const openLoginModal = useContext(AFConfigContext)?.openLoginModal; const ref = React.useRef(null); const [open, setOpen] = React.useState(false); const handleClose = useCallback(() => { @@ -19,6 +22,13 @@ function ReactAction({ comment }: { comment: GlobalComment }) { }, []); const handleOpen = () => { + if (!isAuthenticated && openLoginModal) { + const url = window.location.href + '#comment-' + comment.commentId; + + openLoginModal(url); + return; + } + setOpen(true); };