From b19b381f245ba89b58ce76d24f5dfc711de97adb Mon Sep 17 00:00:00 2001 From: Kiryl Budnik Date: Wed, 18 Oct 2023 11:39:34 +0200 Subject: [PATCH] show project feed item counter even if nothing has been updated --- .../common/components/FeedItem/FeedItem.tsx | 12 +----------- .../ProjectFeedItem/ProjectFeedItem.tsx | 17 +++++++++-------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/pages/common/components/FeedItem/FeedItem.tsx b/src/pages/common/components/FeedItem/FeedItem.tsx index bafa9ab5eb..96b79f19fb 100644 --- a/src/pages/common/components/FeedItem/FeedItem.tsx +++ b/src/pages/common/components/FeedItem/FeedItem.tsx @@ -15,7 +15,6 @@ import { DiscussionFeedCard } from "../DiscussionFeedCard"; import { ProposalFeedCard } from "../ProposalFeedCard"; import { ProjectFeedItem } from "./components"; import { useFeedItemContext } from "./context"; -import { useFeedItemCounters } from "./hooks"; import { FeedItemRef } from "./types"; interface FeedItemProps { @@ -68,8 +67,6 @@ const FeedItem = forwardRef((props, ref) => { const { onFeedItemUpdate, getLastMessage, getNonAllowedItems, onUserSelect } = useFeedItemContext(); useFeedItemSubscription(item.id, commonId, onFeedItemUpdate); - const { projectUnreadStreamsCount, projectUnreadMessages } = - useFeedItemCounters(item.id, commonId); if ( shouldCheckItemVisibility && @@ -118,14 +115,7 @@ const FeedItem = forwardRef((props, ref) => { } if (item.data.type === CommonFeedType.Project) { - return ( - - ); + return ; } return null; diff --git a/src/pages/common/components/FeedItem/components/ProjectFeedItem/ProjectFeedItem.tsx b/src/pages/common/components/FeedItem/components/ProjectFeedItem/ProjectFeedItem.tsx index fdb107b579..ae282dc417 100644 --- a/src/pages/common/components/FeedItem/components/ProjectFeedItem/ProjectFeedItem.tsx +++ b/src/pages/common/components/FeedItem/components/ProjectFeedItem/ProjectFeedItem.tsx @@ -8,28 +8,29 @@ import { OpenIcon } from "@/shared/icons"; import { CommonFeed } from "@/shared/models"; import { CommonAvatar, parseStringToTextEditorValue } from "@/shared/ui-kit"; import { checkIsProject } from "@/shared/utils"; +import { useFeedItemCounters } from "../../hooks"; import styles from "./ProjectFeedItem.module.scss"; interface ProjectFeedItemProps { item: CommonFeed; isMobileVersion: boolean; - unreadStreamsCount?: number; - unreadMessages?: number; } export const ProjectFeedItem: FC = (props) => { - const { item, isMobileVersion, unreadStreamsCount, unreadMessages } = props; + const { item, isMobileVersion } = props; const history = useHistory(); const { getCommonPagePath } = useRoutesContext(); const { renderFeedItemBaseContent } = useFeedItemContext(); const { data: common, fetched: isCommonFetched, fetchCommon } = useCommon(); + const { + projectUnreadStreamsCount: unreadStreamsCount, + projectUnreadMessages: unreadMessages, + } = useFeedItemCounters(item.id, common?.directParent?.commonId); const commonId = item.data.id; const lastMessage = parseStringToTextEditorValue( - Number.isInteger(unreadStreamsCount) - ? `${unreadStreamsCount} updated stream${ - unreadStreamsCount === 1 ? "" : "s" - }` - : undefined, + `${unreadStreamsCount ?? 0} updated stream${ + unreadStreamsCount === 1 ? "" : "s" + }`, ); const isProject = checkIsProject(common); const titleEl = (