Skip to content

Commit

Permalink
inbox items avatar clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
roienatan committed Oct 30, 2023
1 parent 5c3a84c commit f26214e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/pages/common/components/FeedItem/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface FeedItemBaseContentProps {
hasImages?: boolean;
isLoading?: boolean;
shouldHideBottomContent?: boolean;
dmUserId?: string;
}

export interface GetLastMessageOptions {
Expand Down
1 change: 0 additions & 1 deletion src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import {
import { InfiniteScroll, TextEditorValue } from "@/shared/ui-kit";
import {
addQueryParam,
checkIsProject,
deleteQueryParam,
getParamsFromOneOfRoutes,
getUserName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const ChatChannelItem: FC<ChatChannelFeedLayoutItemProps> = (props) => {
ownerId={userId}
renderImage={renderImage}
isImageRounded
dmUserId={dmUserId}
/>
);
};
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -36,10 +40,12 @@ export const FeedItemBaseContent: FC<FeedItemBaseContentProps> = (props) => {
isImageRounded,
isProject,
discussionPredefinedType,
dmUserId,
} = props;
const contextMenuRef = useRef<ContextMenuRef>(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
Expand Down Expand Up @@ -97,6 +103,12 @@ export const FeedItemBaseContent: FC<FeedItemBaseContentProps> = (props) => {
}
};

const handleAvatarClick = () => {
if (onUserSelect && dmUserId) {
onUserSelect(dmUserId);
}
};

return (
<div
className={classNames(styles.container, {
Expand All @@ -108,14 +120,16 @@ export const FeedItemBaseContent: FC<FeedItemBaseContentProps> = (props) => {
onContextMenu={handleContextMenu}
{...getLongPressProps()}
>
{renderImage?.(imageClassName) || (
<CommonAvatar
name={commonName}
src={image}
className={imageClassName}
alt={imageAlt}
/>
)}
<div onClick={handleAvatarClick}>
{renderImage?.(imageClassName) || (
<CommonAvatar
name={commonName}
src={image}
className={imageClassName}
alt={imageAlt}
/>
)}
</div>
<div className={styles.content}>
<div className={styles.topContent}>
<p
Expand Down

0 comments on commit f26214e

Please sign in to comment.