Skip to content

user follow feed - #37

Open
dinesh-2047 wants to merge 1 commit into
Sohaibkundi2:mainfrom
dinesh-2047:repost
Open

user follow feed#37
dinesh-2047 wants to merge 1 commit into
Sohaibkundi2:mainfrom
dinesh-2047:repost

Conversation

@dinesh-2047

@dinesh-2047 dinesh-2047 commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

#20 solved

Summary by CodeRabbit

Release Notes

New Features

  • Introduced a personalized Following feed displaying content from creators you follow, including videos and tweets.
  • Added "Following" navigation item for quick access to your feed.
  • Includes content filtering by type and pagination with Load More functionality.
  • Displays followed channel information and provides exploration options when feed is empty.

@vercel

vercel Bot commented Mar 8, 2026

Copy link
Copy Markdown

@dinesh-2047 is attempting to deploy a commit to the sohaib's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Mar 8, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces a "Following Feed" feature allowing authenticated users to view personalized content from followed creators. Changes include routing setup, API integration, navigation UI updates, and a new page component with filtering, pagination, and empty-state handling.

Changes

Cohort / File(s) Summary
Routing & Navigation
frontend/src/App.jsx, frontend/src/components/Navbar.jsx
Adds protected /following route with FollowingFeedPage and conditionally displays "Following" navigation item for authenticated users in desktop and mobile menus.
API Integration
frontend/src/api/index.js
Adds new getFollowingFeed(params) helper function to fetch subscriptions feed data with query parameters.
Page Component
frontend/src/pages/FollowingFeedPage.jsx
New component implementing personalized following feed with pagination, item filtering (video/tweet/all), loading states, memoized computed counts, empty-state UI, and per-item date headers.

Sequence Diagram

sequenceDiagram
    participant User
    participant App as App Router
    participant FollowingPage as FollowingFeedPage
    participant API
    participant Backend as Backend API

    User->>App: Navigate to /following
    App->>FollowingPage: Render component (mount)
    FollowingPage->>API: getFollowingFeed({page: 1, limit: 12})
    API->>Backend: GET /subscriptions/feed?page=1&limit=12
    Backend->>API: Return feed items, channels, totals
    API->>FollowingPage: Resolve with feed data
    FollowingPage->>FollowingPage: Set state (items, channels, pagination)
    FollowingPage->>User: Render feed with header, filters, content grid
    User->>FollowingPage: Click "Load More"
    FollowingPage->>API: getFollowingFeed({page: 2, limit: 12})
    API->>Backend: GET /subscriptions/feed?page=2&limit=12
    Backend->>API: Return next page items
    API->>FollowingPage: Resolve with additional items
    FollowingPage->>FollowingPage: Append items to state
    FollowingPage->>User: Update feed display
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A following feed hops into view,
With channels and creators anew,
Filters and pagination play,
Loading more content each day,
A burrow of joy, shared with you!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'user follow feed' directly describes the main feature being added: a following feed page for users, which is the central change across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
frontend/src/pages/FollowingFeedPage.jsx (3)

27-47: Consider adding user-facing error feedback.

When the API call fails, the error is only logged to console. Users won't know why the feed is empty or if something went wrong. Consider setting an error state and displaying an error message.

♻️ Proposed fix to add error state
  const [loading, setLoading] = useState(true);
  const [loadingMore, setLoadingMore] = useState(false);
  const [message, setMessage] = useState("");
+ const [error, setError] = useState(null);

  useEffect(() => {
    const fetchFeed = async () => {
      try {
        setLoading(true);
+       setError(null);
        const response = await getFollowingFeed({ page: 1, limit: 12 });
        const data = response.data?.data || {};

        setFeedItems(data.items || []);
        setChannels(data.channels || []);
        setHasMore(Boolean(data.hasMore));
        setTotalItems(data.totalItems || 0);
        setPage(1);
      } catch (error) {
        console.error("Failed to fetch following feed:", error);
+       setError("Failed to load your feed. Please try again later.");
      } finally {
        setLoading(false);
      }
    };

    fetchFeed();
  }, []);

Then render the error state before the empty state check around Line 192.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/pages/FollowingFeedPage.jsx` around lines 27 - 47, Add a
user-facing error state and show it when fetching fails: create a state like
error and setError via useState in the FollowingFeedPage component, update the
catch block inside fetchFeed (which calls getFollowingFeed) to setError(error ||
"Failed to load feed") in addition to console.error, and ensure loading state
(setLoading) is still cleared in finally; then render the error message in the
component UI (place it before the empty-state rendering) so users see the
failure instead of just an empty feed.

75-92: Consider showing error feedback when loading more fails.

Similar to the initial fetch, handleLoadMore only logs errors to console. Users won't know if loading more items failed.

♻️ Proposed improvement
    } catch (error) {
      console.error("Failed to load more following activity:", error);
+     setMessage("Failed to load more items. Please try again.");
    } finally {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/pages/FollowingFeedPage.jsx` around lines 75 - 92,
handleLoadMore currently only logs failures to console so users get no feedback;
update it to set a UI-visible error state and/or trigger the existing app
notification mechanism when an error occurs. In the catch block of
handleLoadMore, call the same user-facing error handler used elsewhere in this
component (e.g., setError or showToast/snackbar) with a concise message like
"Failed to load more items" and include the error details for debugging, and
ensure the component renders that error state or the notification so users see
the failure; keep the existing setLoadingMore(false) in finally and do not
change page state on failure.

250-261: Pagination is disabled when filters are applied.

The "Load more" button only appears when filter === "all". Since filtering is client-side, users viewing only videos or tweets cannot load additional pages. Consider either:

  • Allowing pagination with filters (though new items may not match the current filter)
  • Adding a note explaining why "Load more" isn't available when filtered
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/pages/FollowingFeedPage.jsx` around lines 250 - 261, The Load
more button is currently gated by filter === "all", preventing pagination when a
client-side filter is applied; remove that conditional so the button renders
whenever hasMore is true (i.e., change the JSX condition from hasMore && filter
=== "all" to just hasMore) so handleLoadMore and loadingMore continue to work as
before, and optionally add a short explanatory note near the button that newly
fetched items may not match the active filter if you want to inform users.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/pages/FollowingFeedPage.jsx`:
- Around line 224-230: The map rendering in filteredItems.map uses item.data
directly for the key and tweet prop which can throw if item.data is undefined;
update the map in FollowingFeedPage.jsx (the filteredItems.map -> TweetCard
usage) to defensively access item.data (use optional chaining and a fallback id
like item.data?._id ?? 'unknown' for the key) and only pass a safe value to the
tweet prop (e.g., item.data ?? null) or conditionally render the TweetCard only
when item.data exists; apply the same defensive pattern to the other similar
block that renders TweetCard in this file.

---

Nitpick comments:
In `@frontend/src/pages/FollowingFeedPage.jsx`:
- Around line 27-47: Add a user-facing error state and show it when fetching
fails: create a state like error and setError via useState in the
FollowingFeedPage component, update the catch block inside fetchFeed (which
calls getFollowingFeed) to setError(error || "Failed to load feed") in addition
to console.error, and ensure loading state (setLoading) is still cleared in
finally; then render the error message in the component UI (place it before the
empty-state rendering) so users see the failure instead of just an empty feed.
- Around line 75-92: handleLoadMore currently only logs failures to console so
users get no feedback; update it to set a UI-visible error state and/or trigger
the existing app notification mechanism when an error occurs. In the catch block
of handleLoadMore, call the same user-facing error handler used elsewhere in
this component (e.g., setError or showToast/snackbar) with a concise message
like "Failed to load more items" and include the error details for debugging,
and ensure the component renders that error state or the notification so users
see the failure; keep the existing setLoadingMore(false) in finally and do not
change page state on failure.
- Around line 250-261: The Load more button is currently gated by filter ===
"all", preventing pagination when a client-side filter is applied; remove that
conditional so the button renders whenever hasMore is true (i.e., change the JSX
condition from hasMore && filter === "all" to just hasMore) so handleLoadMore
and loadingMore continue to work as before, and optionally add a short
explanatory note near the button that newly fetched items may not match the
active filter if you want to inform users.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb21b378-e730-4605-80cc-46f3d408b722

📥 Commits

Reviewing files that changed from the base of the PR and between f3b62ab and cdd9629.

📒 Files selected for processing (4)
  • frontend/src/App.jsx
  • frontend/src/api/index.js
  • frontend/src/compunents/Navbar.jsx
  • frontend/src/pages/FollowingFeedPage.jsx

Comment on lines +224 to +230
{filteredItems.map((item) => (
<TweetCard
key={`${item.type}-${item.data._id}`}
tweet={item.data}
onMessage={setMessage}
/>
))}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add defensive access for item.data in keys and rendering.

The key generation item.data._id will throw a TypeError if item.data is undefined. Consider using optional chaining or providing a fallback.

🛡️ Proposed fix for safer key generation
-              <TweetCard
-                key={`${item.type}-${item.data._id}`}
+              <TweetCard
+                key={`${item.type}-${item.data?._id ?? item._id}`}
-            <div key={`${item.type}-${item.data._id}`} className="space-y-3">
+            <div key={`${item.type}-${item.data?._id ?? item._id}`} className="space-y-3">

Also applies to: 234-246

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/pages/FollowingFeedPage.jsx` around lines 224 - 230, The map
rendering in filteredItems.map uses item.data directly for the key and tweet
prop which can throw if item.data is undefined; update the map in
FollowingFeedPage.jsx (the filteredItems.map -> TweetCard usage) to defensively
access item.data (use optional chaining and a fallback id like item.data?._id ??
'unknown' for the key) and only pass a safe value to the tweet prop (e.g.,
item.data ?? null) or conditionally render the TweetCard only when item.data
exists; apply the same defensive pattern to the other similar block that renders
TweetCard in this file.

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