Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Streamline Post fragments and it's types #5540

Merged
merged 7 commits into from
Mar 2, 2025
Merged

Conversation

bigint
Copy link
Member

@bigint bigint commented Mar 2, 2025

No description provided.

@bigint bigint requested a review from Copilot March 2, 2025 06:23

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors various components by replacing legacy Post and Timeline types with their new Fragment counterparts. The changes streamline the type definitions across the components handling posts, timelines, and related interactions.

  • Updated type imports from Post, TimelineItem, Repost, etc., to their new Fragment versions.
  • Removed explicit type casts in favor of passing the updated types directly.
  • Adjusted components across the codebase (e.g., ImageFeed, Timeline, Composer, OG page) to support the new type definitions.

Reviewed Changes

File Description
apps/web/src/components/Explore/ImageFeed.tsx Removed explicit cast on the post in SingleImagePost to pass the new fragment type
apps/web/src/components/Composer/NewPublication.tsx Updated component prop types from Post to PostFragment
apps/web/src/components/Post/Actions/Like.tsx Replaced Post type with PostFragment in reaction-related code
apps/web/src/components/Home/ForYou.tsx Removed cast in SinglePost component to align with new post type
apps/web/src/components/Home/Timeline/EventType/Combined.tsx Changed TimelineItem import to TimelineItemFragment
apps/web/src/components/Home/Timeline/index.tsx Removed type cast on timelineItem.primary in SinglePost
apps/web/src/components/Comment/CommentFeed.tsx Removed cast from comment to use the default post fragment type
apps/web/src/components/Bookmarks/BookmarksFeed.tsx Updated post type from Post to PostFragment in bookmark feed rendering
apps/web/src/components/Home/Timeline/EventType/Reposted.tsx Changed type from Repost to RepostFragment
apps/web/src/components/Explore/ExploreFeed.tsx Removed cast from post in the explore feed component
apps/web/src/components/Comment/NoneRelevantFeed.tsx Updated post type conversion in comment feed without casting
apps/web/src/components/Group/GroupFeed.tsx Removed unnecessary casting on post in the group feed
apps/web/src/components/Post/Actions/Comment.tsx Updated prop type for Comment from Post to PostFragment
apps/web/src/components/Home/Timeline/EventType/index.tsx Changed TimelineItem to TimelineItemFragment in action types
apps/web/src/components/Account/AccountFeed.tsx Replaced Post casts with direct post pass using PostFragment
apps/web/src/components/Post/Actions/Menu/Bookmark.tsx Updated Bookmark action to use PostFragment
apps/web/src/components/Post/Actions/Menu/HideComment.tsx Updated HideComment component to accept PostFragment
apps/web/src/components/Post/Actions/Menu/CopyPostText.tsx Changed CopyPostText to use PostFragment
apps/web/src/components/Post/Actions/Menu/Delete.tsx Updated Delete action to use PostFragment
apps/og/src/app/posts/[id]/page.tsx Updated the OpenGraph page to cast post as AnyPostFragment instead of AnyPost

Copilot reviewed 63 out of 63 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

apps/web/src/components/Explore/ImageFeed.tsx:53

  • Removing the explicit cast from 'AnyPost' to use the raw post object might expose type mismatches if SingleImagePost is not updated to accept the PostFragment type; please verify SingleImagePost's prop types.
<SingleImagePost key={post.id} post={post} />

apps/web/src/components/Composer/NewPublication.tsx:51

  • The prop type for 'post' was changed from Post to PostFragment; ensure that all components (such as QuotedPost) using this prop are updated to handle the new type structure.
post?: PostFragment;

apps/web/src/components/Home/Timeline/index.tsx:76

  • The removal of the explicit cast from Post to the timelineItem.primary could lead to type incompatibility issues if SinglePost has not been refactored to expect the new fragment type; please double-check the expected prop types.
post={timelineItem.primary}

apps/og/src/app/posts/[id]/page.tsx:30

  • Changing the cast from AnyPost to AnyPostFragment requires verifying that subsequent usage of 'post' aligns with the properties defined in the fragment; please review any downstream dependencies.
const post = data.post as AnyPostFragment;
@bigint bigint requested a review from Copilot March 2, 2025 06:44
@bigint bigint merged commit d6b0493 into main Mar 2, 2025
2 checks passed
@bigint bigint deleted the ref-post-types branch March 2, 2025 06:45

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request refactors various components to use streamlined post fragment types instead of the older post types and removes redundant type casts. The changes improve code consistency and maintainability by updating the type definitions across components.

  • Updated type imports across multiple components from Post, TimelineItem, and Repost to PostFragment, TimelineItemFragment, and RepostFragment.
  • Removed unnecessary type casts to simplify components' props.
  • Adjusted state management in NewPublication by modifying the argument passed to setQuotedPost.

Reviewed Changes

File Description
apps/web/src/components/Explore/ImageFeed.tsx Removed type cast from SingleImagePost component.
apps/web/src/components/Composer/NewPublication.tsx Updated post type and modified setQuotedPost argument.
apps/web/src/components/Post/Actions/Like.tsx Replaced Post type with PostFragment.
apps/web/src/components/Home/ForYou.tsx Removed type cast from SinglePost component.
apps/web/src/components/Home/Timeline/index.tsx Updated timeline item and post type usage.
apps/web/src/components/Comment/NoneRelevantFeed.tsx Removed type cast from SinglePost component.
apps/web/src/components/Comment/CommentFeed.tsx Removed type cast from SinglePost component.
apps/web/src/components/Post/Actions/Comment.tsx Replaced Post type with PostFragment.
apps/web/src/components/Home/Timeline/EventType/Combined.tsx Updated timeline item type to TimelineItemFragment.
apps/web/src/components/Home/Timeline/EventType/Reposted.tsx Updated repost type to RepostFragment.
apps/web/src/components/Group/GroupFeed.tsx Removed type cast from SinglePost component.
apps/web/src/components/Explore/ExploreFeed.tsx Removed type cast from SinglePost component.
apps/web/src/components/Bookmarks/BookmarksFeed.tsx Removed type cast from SinglePost component.
apps/web/src/components/Home/Timeline/EventType/index.tsx Updated timeline item type to TimelineItemFragment.
apps/web/src/components/Account/AccountFeed.tsx Removed type cast from SinglePost component.
apps/web/src/components/Post/Actions/Menu/Bookmark.tsx Replaced Post type with PostFragment.
apps/web/src/components/Post/Actions/Menu/CopyPostText.tsx Replaced Post type with PostFragment.
apps/web/src/components/Post/Actions/Menu/Delete.tsx Replaced Post type with PostFragment.
apps/web/src/components/Post/Actions/Menu/HideComment.tsx Replaced Post type with PostFragment.
apps/og/src/app/posts/[id]/page.tsx Updated post type to AnyPostFragment for metadata generation.

Copilot reviewed 80 out of 80 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

apps/web/src/components/Composer/NewPublication.tsx:112

  • Removing the null argument in setQuotedPost() may lead to unintended behavior if the function is designed to clear the quoted post by receiving an explicit null. Consider either reverting back to passing null or updating the function's implementation accordingly.
setQuotedPost();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant