Skip to content

Commit

Permalink
fix created item selection
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Sep 12, 2023
1 parent ace6922 commit d43345d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
7 changes: 5 additions & 2 deletions src/pages/commonFeed/CommonFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ const CommonFeedComponent: FC<CommonFeedProps> = (props) => {
checkIsFeedItemFollowLayoutItem(firstItem) &&
recentStreamId === firstItem.feedItem.data.id
) {
feedLayoutRef?.setShouldAllowChatAutoOpen(true);
feedLayoutRef?.setExpandedFeedItemId(firstItem.feedItem.id);
feedLayoutRef?.setActiveItem({
feedItemId: firstItem.feedItem.id,
circleVisibility: [],
});
dispatch(commonActions.setRecentStreamId(""));
}
}, [feedLayoutRef, recentStreamId, firstItem]);

Expand Down
28 changes: 1 addition & 27 deletions src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React, {
useRef,
useState,
} from "react";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { useHistory } from "react-router-dom";
import { useWindowSize } from "react-use";
import classNames from "classnames";
Expand Down Expand Up @@ -66,7 +66,6 @@ import {
getParamsFromOneOfRoutes,
getUserName,
} from "@/shared/utils";
import { commonActions, selectRecentStreamId } from "@/store/states";
import { MIN_CHAT_WIDTH } from "../../constants";
import {
DesktopChat,
Expand Down Expand Up @@ -169,15 +168,13 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
outerStyles,
settings,
} = props;
const dispatch = useDispatch();
const { getCommonPagePath } = useRoutesContext();
const refsByItemId = useRef<Record<string, FeedItemRef | null>>({});
const { width: windowWidth } = useWindowSize();
const history = useHistory();
const queryParams = useQueryParams();
const isTabletView = useIsTabletView();
const user = useSelector(selectUser());
const recentStreamId = useSelector(selectRecentStreamId);
const userId = user?.uid;
const [chatItem, setChatItem] = useState<ChatItem | null>();
const [isShowFeedItemDetailsModal, setIsShowFeedItemDetailsModal] =
Expand Down Expand Up @@ -270,19 +267,9 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
) {
return;
}
if (recentStreamId) {
const foundItem = allFeedItems.find(
(item) =>
checkIsFeedItemFollowLayoutItem(item) &&
item.feedItem.data.id === recentStreamId,
);
return foundItem?.itemId;
}

if (sharedFeedItemId) {
return sharedFeedItemId;
}

if (chatItem?.feedItemId) {
return;
}
Expand All @@ -300,7 +287,6 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
chatChannelItemForProfile?.itemId,
allFeedItems,
chatItem?.feedItemId,
recentStreamId,
sharedFeedItemId,
userForProfile.userForProfileData,
shouldAllowChatAutoOpen,
Expand Down Expand Up @@ -633,18 +619,6 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
}
}, [isTabletView, shouldAutoExpandItem, activeFeedItemId]);

useEffect(() => {
if (!recentStreamId || !selectedFeedItem) {
return;
}
if (
!checkIsFeedItemFollowLayoutItem(selectedFeedItem) ||
recentStreamId === selectedFeedItem?.feedItem.data.id
) {
dispatch(commonActions.setRecentStreamId(""));
}
}, [recentStreamId, selectedFeedItem]);

useImperativeHandle(
ref,
() => ({
Expand Down

0 comments on commit d43345d

Please sign in to comment.