diff --git a/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx b/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx index 0ecf31b59d..54eb9d3883 100644 --- a/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx +++ b/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx @@ -8,6 +8,7 @@ import React, { import { useDispatch, useSelector } from "react-redux"; import { useUpdateEffect } from "react-use"; import { debounce } from "lodash"; +import copyToClipboard from "copy-to-clipboard"; import { selectUser } from "@/pages/Auth/store/selectors"; import { DiscussionService } from "@/services"; import { DeletePrompt, GlobalOverlay, ReportModal } from "@/shared/components"; @@ -33,10 +34,9 @@ import { PredefinedTypes, } from "@/shared/models"; import { TextEditorValue } from "@/shared/ui-kit"; -import { StaticLinkType, getUserName, InternalLinkData, generateFirstMessage } from "@/shared/utils"; +import { StaticLinkType, getUserName, InternalLinkData, generateFirstMessage, generateStaticShareLink } from "@/shared/utils"; import { useChatContext } from "../ChatComponent"; import { FeedCard } from "../FeedCard"; -import { FeedCardShare } from "../FeedCard"; import { FeedItemRef, GetLastMessageOptions, @@ -122,11 +122,6 @@ function DiscussionFeedCard(props, ref) { onOpen: onReportModalOpen, onClose: onReportModalClose, } = useModal(false); - const { - isShowing: isShareModalOpen, - onOpen: onShareModalOpen, - onClose: onShareModalClose, - } = useModal(false); const { isShowing: isDeleteModalOpen, onOpen: onDeleteModalOpen, @@ -194,7 +189,12 @@ function DiscussionFeedCard(props, ref) { }, { report: onReportModalOpen, - share: () => onShareModalOpen(), + share: () => { + if(discussion) { + copyToClipboard(generateStaticShareLink(StaticLinkType.Discussion, discussion, item.id)); + notify("The link has copied!"); + } + }, remove: onDeleteModalOpen, linkStream: onLinkStreamModalOpen, unlinkStream: onUnlinkStreamModalOpen, @@ -464,15 +464,6 @@ function DiscussionFeedCard(props, ref) { type={EntityTypes.Discussion} /> )} - {discussion && ( - - )} {isDeleteModalOpen && ( ( setHovering(isMouseEnter); }; const proposalId = item.data.id; - const { - isShowing: isShareModalOpen, - onOpen: onShareModalOpen, - onClose: onShareModalClose, - } = useModal(false); const preloadDiscussionMessagesData = usePreloadDiscussionMessagesById({ commonId, discussionId: discussion?.id, @@ -202,7 +198,12 @@ const ProposalFeedCard = forwardRef( }, { report: () => {}, - share: () => onShareModalOpen(), + share: () => { + if(discussion) { + copyToClipboard(generateStaticShareLink(StaticLinkType.Proposal, discussion, item.id)); + notify("The link has copied!"); + } + }, remove: onProposalDeleteModalOpen, markFeedItemAsSeen, markFeedItemAsUnseen, @@ -457,15 +458,6 @@ const ProposalFeedCard = forwardRef( /> )} - {discussion && ( - - )} {isProposalDeleteModalOpen && ( = (props) => { const { common, commonMember, commonFollow, onClick, onSearchClick } = props; - const { - isShowing: isShareModalOpen, - onOpen: onShareModalOpen, - onClose: onShareModalClose, - } = useModal(false); + const { notify } = useNotification(); const { markCommonAsSeen } = useUpdateCommonSeenState(); + const shareLink = generateStaticShareLink(StaticLinkType.Common, common); const items = useMenuItems( { common, @@ -32,23 +29,21 @@ const ActionsButton: FC = (props) => { isSearchActionAvailable: Boolean(onSearchClick), }, { - share: onShareModalOpen, + share: () => { + copyToClipboard(shareLink); + notify("The link has copied!"); + }, onFollowToggle: commonFollow.onFollowToggle, onSearchClick, markCommonAsSeen }, ); - const shareLink = generateStaticShareLink(StaticLinkType.Common, common); + const triggerEl = ; return ( <> {items.length > 0 && } - ); }; diff --git a/src/shared/components/ElementDropdown/ElementDropdown.tsx b/src/shared/components/ElementDropdown/ElementDropdown.tsx index 1e5c09ef83..52b904e9f4 100644 --- a/src/shared/components/ElementDropdown/ElementDropdown.tsx +++ b/src/shared/components/ElementDropdown/ElementDropdown.tsx @@ -261,7 +261,8 @@ const ElementDropdown: FC = ({ switch (selectedItem) { case ElementDropdownMenuItems.Share: - onOpen(); + copyToClipboard(staticShareLink); + notify("The link has copied!"); break; case ElementDropdownMenuItems.Copy: copyToClipboard(