From f26214e6e7c1343c979b0c69f808b47cb5fbefe4 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Mon, 30 Oct 2023 12:26:23 -0400 Subject: [PATCH 1/2] inbox items avatar clickable --- .../common/components/FeedItem/context.ts | 1 + .../components/FeedLayout/FeedLayout.tsx | 1 - .../ChatChannelItem/ChatChannelItem.tsx | 1 + .../FeedItemBaseContent.tsx | 32 +++++++++++++------ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/pages/common/components/FeedItem/context.ts b/src/pages/common/components/FeedItem/context.ts index 67cf765193..f7f7c2f35d 100644 --- a/src/pages/common/components/FeedItem/context.ts +++ b/src/pages/common/components/FeedItem/context.ts @@ -42,6 +42,7 @@ export interface FeedItemBaseContentProps { hasImages?: boolean; isLoading?: boolean; shouldHideBottomContent?: boolean; + dmUserId?: string; } export interface GetLastMessageOptions { diff --git a/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx b/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx index 1ad096f4b4..93441ebc08 100644 --- a/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx +++ b/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx @@ -63,7 +63,6 @@ import { import { InfiniteScroll, TextEditorValue } from "@/shared/ui-kit"; import { addQueryParam, - checkIsProject, deleteQueryParam, getParamsFromOneOfRoutes, getUserName, diff --git a/src/pages/inbox/components/ChatChannelItem/ChatChannelItem.tsx b/src/pages/inbox/components/ChatChannelItem/ChatChannelItem.tsx index 86b964072f..9d9880c345 100644 --- a/src/pages/inbox/components/ChatChannelItem/ChatChannelItem.tsx +++ b/src/pages/inbox/components/ChatChannelItem/ChatChannelItem.tsx @@ -129,6 +129,7 @@ export const ChatChannelItem: FC = (props) => { ownerId={userId} renderImage={renderImage} isImageRounded + dmUserId={dmUserId} /> ); }; diff --git a/src/pages/inbox/components/FeedItemBaseContent/FeedItemBaseContent.tsx b/src/pages/inbox/components/FeedItemBaseContent/FeedItemBaseContent.tsx index 04238c3472..438a80d52f 100644 --- a/src/pages/inbox/components/FeedItemBaseContent/FeedItemBaseContent.tsx +++ b/src/pages/inbox/components/FeedItemBaseContent/FeedItemBaseContent.tsx @@ -1,7 +1,11 @@ import React, { FC, MouseEventHandler, useRef, useState } from "react"; import classNames from "classnames"; import { useLongPress } from "use-long-press"; -import { FeedCardTags, FeedItemBaseContentProps } from "@/pages/common"; +import { + FeedCardTags, + FeedItemBaseContentProps, + useFeedItemContext, +} from "@/pages/common"; import { PredefinedTypes } from "@/shared/models"; import { ContextMenu, @@ -36,10 +40,12 @@ export const FeedItemBaseContent: FC = (props) => { isImageRounded, isProject, discussionPredefinedType, + dmUserId, } = props; const contextMenuRef = useRef(null); const [isLongPressing, setIsLongPressing] = useState(false); const [isLongPressed, setIsLongPressed] = useState(false); + const { onUserSelect } = useFeedItemContext(); const isContextMenuEnabled = Boolean(menuItems && menuItems.length > 0); const finalTitle = discussionPredefinedType === PredefinedTypes.General && commonName @@ -97,6 +103,12 @@ export const FeedItemBaseContent: FC = (props) => { } }; + const handleAvatarClick = () => { + if (onUserSelect && dmUserId) { + onUserSelect(dmUserId); + } + }; + return (
= (props) => { onContextMenu={handleContextMenu} {...getLongPressProps()} > - {renderImage?.(imageClassName) || ( - - )} +
+ {renderImage?.(imageClassName) || ( + + )} +

Date: Mon, 30 Oct 2023 12:45:11 -0400 Subject: [PATCH 2/2] inbox feed item common/space avatar click now redirects to the common/space --- .../components/DiscussionFeedCard/DiscussionFeedCard.tsx | 1 + src/pages/common/components/FeedCard/FeedCard.tsx | 3 +++ src/pages/common/components/FeedItem/context.ts | 1 + .../components/ProposalFeedCard/ProposalFeedCard.tsx | 1 + .../components/FeedItemBaseContent/FeedItemBaseContent.tsx | 7 +++++++ 5 files changed, 13 insertions(+) diff --git a/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx b/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx index 4e2641abd4..721c6102c3 100644 --- a/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx +++ b/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx @@ -321,6 +321,7 @@ const DiscussionFeedCard = forwardRef( isPreviewMode={isPreviewMode} isPinned={isPinned} commonName={commonName} + commonId={commonId} image={commonImage} imageAlt={`${commonName}'s image`} isProject={isProject} diff --git a/src/pages/common/components/FeedCard/FeedCard.tsx b/src/pages/common/components/FeedCard/FeedCard.tsx index 84011cb894..b2d428e9a0 100644 --- a/src/pages/common/components/FeedCard/FeedCard.tsx +++ b/src/pages/common/components/FeedCard/FeedCard.tsx @@ -31,6 +31,7 @@ type FeedCardProps = PropsWithChildren<{ lastMessage?: TextEditorValue; isPreviewMode?: boolean; commonName?: string; + commonId?: string; image?: string; imageAlt?: string; isProject?: boolean; @@ -69,6 +70,7 @@ export const FeedCard = forwardRef((props, ref) => { lastMessage, isPreviewMode = true, commonName, + commonId, image, imageAlt, isProject, @@ -192,6 +194,7 @@ export const FeedCard = forwardRef((props, ref) => { lastMessage: !isLoading ? lastMessage : undefined, menuItems, commonName, + commonId, image, imageAlt, isProject, diff --git a/src/pages/common/components/FeedItem/context.ts b/src/pages/common/components/FeedItem/context.ts index f7f7c2f35d..db388eb6fb 100644 --- a/src/pages/common/components/FeedItem/context.ts +++ b/src/pages/common/components/FeedItem/context.ts @@ -29,6 +29,7 @@ export interface FeedItemBaseContentProps { seen?: boolean; ownerId?: string; commonName?: string; + commonId?: string; renderImage?: (className?: string) => ReactNode; renderLeftContent?: () => ReactNode; image?: string; diff --git a/src/pages/common/components/ProposalFeedCard/ProposalFeedCard.tsx b/src/pages/common/components/ProposalFeedCard/ProposalFeedCard.tsx index 934cd0720d..6259c659ef 100644 --- a/src/pages/common/components/ProposalFeedCard/ProposalFeedCard.tsx +++ b/src/pages/common/components/ProposalFeedCard/ProposalFeedCard.tsx @@ -458,6 +458,7 @@ const ProposalFeedCard = forwardRef( seen={feedItemUserMetadata?.seen ?? !isFeedItemUserMetadataFetched} menuItems={menuItems} ownerId={item.userId} + commonId={commonId} > {renderContent()} diff --git a/src/pages/inbox/components/FeedItemBaseContent/FeedItemBaseContent.tsx b/src/pages/inbox/components/FeedItemBaseContent/FeedItemBaseContent.tsx index 438a80d52f..56055f4658 100644 --- a/src/pages/inbox/components/FeedItemBaseContent/FeedItemBaseContent.tsx +++ b/src/pages/inbox/components/FeedItemBaseContent/FeedItemBaseContent.tsx @@ -1,4 +1,5 @@ import React, { FC, MouseEventHandler, useRef, useState } from "react"; +import { useHistory } from "react-router-dom"; import classNames from "classnames"; import { useLongPress } from "use-long-press"; import { @@ -6,6 +7,7 @@ import { FeedItemBaseContentProps, useFeedItemContext, } from "@/pages/common"; +import { useRoutesContext } from "@/shared/contexts"; import { PredefinedTypes } from "@/shared/models"; import { ContextMenu, @@ -41,7 +43,10 @@ export const FeedItemBaseContent: FC = (props) => { isProject, discussionPredefinedType, dmUserId, + commonId, } = props; + const history = useHistory(); + const { getCommonPagePath } = useRoutesContext(); const contextMenuRef = useRef(null); const [isLongPressing, setIsLongPressing] = useState(false); const [isLongPressed, setIsLongPressed] = useState(false); @@ -106,6 +111,8 @@ export const FeedItemBaseContent: FC = (props) => { const handleAvatarClick = () => { if (onUserSelect && dmUserId) { onUserSelect(dmUserId); + } else if (commonId) { + history.push(getCommonPagePath(commonId)); } };