Skip to content

Commit

Permalink
Merge pull request #141 from Dev-FE-1/hotfix/timeline-posts-duplicate…
Browse files Browse the repository at this point in the history
…-137

[Bug] 타임라인 게시물 중복 해결, 타임라인에 본인 포스트가 올라오지 않는 오류 해결(#137)
  • Loading branch information
devdeun authored Sep 9, 2024
2 parents dbb3a56 + 2402fda commit 9904502
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/fetchPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const getPostsByFollowingUsers = async ({
return [];
}

const followingUserIds = userDoc.data().following;
const followingUserIds = userDoc.data().following ?? [];

let q = query(
postsCollection,
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/useFilteredPostsTimelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ export const useFilteredPostsTimelinesQuery = ({ userId }: { userId: string }) =
const noneFollowingUserPosts = await getPostsByNonFollowingUsers({
userId,
count: POSTS_FETCH_LIMIT,
lastPostId: pageParam as string | undefined,
lastPostId:
followingUserPosts[followingUserPosts.length - 1]?.postId ||
(pageParam as string | undefined),
});
posts = noneFollowingUserPosts;
posts = [...followingUserPosts, ...noneFollowingUserPosts];
}
return {
posts: posts,
nextCursor: posts.length === POSTS_FETCH_LIMIT ? posts[posts.length - 1].postId : null,
nextCursor: posts.length > 2 ? posts[posts.length - 1].postId : null,
};
},
getNextPageParam: (lastPage) => lastPage.nextCursor,
Expand Down

0 comments on commit 9904502

Please sign in to comment.