Skip to content

Commit

Permalink
Merge branch 'dev' into cw-2072-enable-editing-circles-roles-names
Browse files Browse the repository at this point in the history
  • Loading branch information
roienatan committed Sep 20, 2023
2 parents b5e58ef + a99f9bb commit 375dd0e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
isFollowing={feedItemFollow.isFollowing}
isLoading={isLoading}
menuItems={menuItems}
seenOnce={feedItemUserMetadata?.seenOnce}
seen={feedItemUserMetadata?.seen}
seenOnce={feedItemUserMetadata?.seenOnce ?? true}
seen={feedItemUserMetadata?.seen ?? true}
ownerId={item.userId}
discussionPredefinedType={discussion?.predefinedType}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ const ProposalFeedCard = forwardRef<FeedItemRef, ProposalFeedCardProps>(
isFollowing={feedItemFollow.isFollowing}
isLoading={isLoading}
type={item.data.type}
seenOnce={feedItemUserMetadata?.seenOnce}
seen={feedItemUserMetadata?.seen}
seenOnce={feedItemUserMetadata?.seenOnce ?? true}
seen={feedItemUserMetadata?.seen ?? true}
menuItems={menuItems}
ownerId={item.userId}
>
Expand Down
20 changes: 14 additions & 6 deletions src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,20 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
return;
}

const foundItem = allFeedItems?.find(
(item) =>
!checkIsFeedItemFollowLayoutItem(item) ||
[CommonFeedType.Proposal, CommonFeedType.Discussion].includes(
const foundItem = allFeedItems?.find((item) => {
if (!checkIsFeedItemFollowLayoutItem(item)) {
return true;
}
if (
![CommonFeedType.Proposal, CommonFeedType.Discussion].includes(
item.feedItem.data.type,
),
);
)
) {
return false;
}

return Boolean(userId) || item.feedItem.circleVisibility.length === 0;
});

return foundItem?.itemId;
}, [
Expand All @@ -289,6 +296,7 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
sharedFeedItemId,
userForProfile.userForProfileData,
shouldAllowChatAutoOpen,
userId,
]);
const activeFeedItemId = chatItem?.feedItemId || feedItemIdForAutoChatOpen;
const sizeKey = `${windowWidth}_${chatWidth}`;
Expand Down
20 changes: 13 additions & 7 deletions src/shared/hooks/useCases/useFeedItemUserMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,25 @@ export const useFeedItemUserMetadata = (): Return => {

const fetchFeedItemUserMetadata = useCallback(
(info: IdentificationInfo) => {
setDefaultState({ ...DEFAULT_STATE });
setDefaultState({
...DEFAULT_STATE,
fetched: !info.userId,
});
setIdentificationInfo(info);
dispatch(
cacheActions.getFeedItemUserMetadata.request({
payload: info,
}),
);

if (info.userId) {
dispatch(
cacheActions.getFeedItemUserMetadata.request({
payload: info,
}),
);
}
},
[dispatch],
);

useEffect(() => {
if (!identificationInfo) {
if (!identificationInfo || !identificationInfo.userId) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions src/store/states/common/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export const reducer = createReducer<CommonState, Action>(initialState)
produce(state, (nextState) => {
nextState.feedItems = {
...nextState.feedItems,
data: nextState.feedItems.data || [],
loading: false,
hasMore: false,
lastDocTimestamp: null,
Expand All @@ -444,6 +445,7 @@ export const reducer = createReducer<CommonState, Action>(initialState)
produce(state, (nextState) => {
nextState.pinnedFeedItems = {
...nextState.pinnedFeedItems,
data: nextState.pinnedFeedItems.data || [],
loading: false,
};
}),
Expand Down

0 comments on commit 375dd0e

Please sign in to comment.