Skip to content

Commit

Permalink
show project feed item counter even if nothing has been updated
Browse files Browse the repository at this point in the history
  • Loading branch information
budnik9 committed Oct 18, 2023
1 parent 63ba32d commit b19b381
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
12 changes: 1 addition & 11 deletions src/pages/common/components/FeedItem/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -68,8 +67,6 @@ const FeedItem = forwardRef<FeedItemRef, FeedItemProps>((props, ref) => {
const { onFeedItemUpdate, getLastMessage, getNonAllowedItems, onUserSelect } =
useFeedItemContext();
useFeedItemSubscription(item.id, commonId, onFeedItemUpdate);
const { projectUnreadStreamsCount, projectUnreadMessages } =
useFeedItemCounters(item.id, commonId);

if (
shouldCheckItemVisibility &&
Expand Down Expand Up @@ -118,14 +115,7 @@ const FeedItem = forwardRef<FeedItemRef, FeedItemProps>((props, ref) => {
}

if (item.data.type === CommonFeedType.Project) {
return (
<ProjectFeedItem
item={item}
isMobileVersion={isMobileVersion}
unreadStreamsCount={projectUnreadStreamsCount}
unreadMessages={projectUnreadMessages}
/>
);
return <ProjectFeedItem item={item} isMobileVersion={isMobileVersion} />;
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProjectFeedItemProps> = (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 = (
Expand Down

0 comments on commit b19b381

Please sign in to comment.