Skip to content

My favorites widget - #670

Merged
feruzm merged 8 commits into
developfrom
myfav
Feb 22, 2026
Merged

My favorites widget#670
feruzm merged 8 commits into
developfrom
myfav

Conversation

@feruzm

@feruzmferuzm commented Feb 22, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • My Favorites widget added to the feed with a "View all" button that opens bookmarks on the Favorites tab.
  • Improvements

    • Informational hints added to Bookmarks and Favorites views.
    • Favorite-related UI and labels standardized to American spelling.
    • Deletions for favorites and drafts now use optimistic updates for snappier UI feedback.
  • Tests

    • Added unit tests for the favorite item component.

@coderabbitai

coderabbitaiBot commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Adds a MyFavoritesWidget to the feed sidebar, renames bookmarks/favourites APIs and components to "favorites", implements optimistic cache updates for delete mutations, adds i18n strings and UI hints, updates tests/exports, and adjusts a z-index.

Changes

Cohort / File(s)Summary
MyFavoritesWidget
apps/web/src/app/_components/my-favorites-widget/index.tsx, apps/web/src/app/_components/index.ts, apps/web/src/app/(dynamicPages)/feed/layout.tsx
New client widget rendered in feed sidebar; fetches up to 5 favorites (with token), shows skeleton/empty/error states, and opens BookmarksDialog (initialTab="favorites"). Widget re-exported and inserted into layout.
Bookmarks / Favorites rename & UI hints
apps/web/src/features/shared/bookmarks/favorite-item.tsx, apps/web/src/features/shared/bookmarks/favorites-list.tsx, apps/web/src/features/shared/bookmarks/index.tsx, apps/web/src/features/shared/bookmarks/bookmarks-list.tsx
Renamed British → US spellings (Favourite* → Favorite*, getFavourites→getFavorites, etc.), added hint i18n keys and rendered hint paragraphs, and added optional `initialTab?: "bookmarks"
SDK: favorites API & query-key renames
packages/sdk/src/modules/accounts/queries/*, packages/sdk/src/modules/core/query-keys.ts, packages/sdk/src/modules/accounts/mutations/index.ts, packages/sdk/src/modules/accounts/mutations/favorites/*, packages/sdk/src/modules/accounts/mutations/favourites/index.ts
Renamed query/mutation modules and QueryKeys from "favourites" → "favorites"; added new favorites mutation hooks and re-exports; removed legacy favourites re-exports; updated error strings and query key builders.
Optimistic delete mutations
packages/sdk/src/modules/accounts/mutations/favorites/use-account-favorite-delete.ts, packages/sdk/src/modules/posts/mutations/use-delete-draft.ts
Introduced onMutate-based optimistic updates: cancel related queries, remove target from list and infinite caches, return previous state for rollback, restore on error and invalidate on success.
Favorite button & hooks updates
apps/web/src/features/shared/favorite-btn/index.tsx, apps/web/src/features/shared/favorite-btn/index.spec.tsx
Renamed component and hooks to American spelling (FavouriteBtn → FavoriteBtn, useAccountFavourite* → useAccountFavorite*), updated imports, query usage, and tests/mocks to match renamed APIs.
Tests & specs
apps/web/src/specs/features/shared/bookmarks.spec.tsx, apps/web/src/specs/features/shared/favorite-item.spec.tsx
Updated mocks to reference renamed FavoritesList; added unit tests for FavoriteItem verifying accessToken propagation and delete mutation invocation.
Exports & index
apps/web/src/app/_components/index.ts, packages/sdk/src/modules/accounts/mutations/favorites/index.ts, packages/sdk/src/modules/accounts/queries/index.ts
Added/updated re-exports for new favorites modules and widget component; removed old favourites re-exports.
Styling
apps/web/src/features/shared/feedback/_index.scss
Adjusted .feedback-container z-index from 1050 to 1055.
i18n
apps/web/src/features/i18n/locales/en-US.json
Added my-favorites-widget translation object and hint strings for bookmarks and favorites.

Sequence Diagram(s)

sequenceDiagram
participant User as User
participant FeedLayout as FeedLayout
participant Widget as MyFavoritesWidget
participant Query as useQuery
participant API as API
participant Dialog as BookmarksDialog
User->>FeedLayout: Open feed page
FeedLayout->>Widget: Render widget in sidebar
Widget->>Widget: Resolve active username & access token
Widget->>Query: Fetch favorites (enabled if token)
Query->>API: GET /accounts/{username}/favorites
API-->>Query: Return favorites list
Query-->>Widget: Provide data
alt No favorites
Widget-->>User: Show empty state + Discover link
else ≤ 5 favorites
Widget-->>User: Render up to 5 favorites
else > 5 favorites
Widget-->>User: Render first 5 + "View all"
User->>Widget: Click "View all"
Widget->>Dialog: Open with initialTab="favorites"
Dialog-->>User: Show full favorites list
end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

patch

Poem

🐰 A tiny widget hopped into the feed,
I sniffed out favorites — five's all I need,
I nudged the cache with hopeful little paws,
Spelled things tidy and adjusted the laws,
Sidebar snug, I hum a happy deed.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 10.53% 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 nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe pull request title 'My favorites widget' accurately reflects the main change: adding a new MyFavoritesWidget component and integrating it into the feed layout.

✏️ 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
  • Commit unit tests in branch myfav

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[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@packages/sdk/src/modules/accounts/mutations/favorites/use-account-favorite-delete.ts`:
- Around line 83-89: The onSuccess handler currently calls qc.invalidateQueries
for QueryKeys.accounts.checkFavorite with possibly undefined username or
account; update onSuccess to guard/normalize inputs and pass the correct
identifier (e.g., the target account id or username expected by
QueryKeys.accounts.checkFavorite) before invalidating. Specifically, inside
onSuccess (function name) ensure username and account are non-null (use
username! or an explicit if-check) and pass the exact value the checkFavorite
key expects (for example account.id or account.username) when calling
qc.invalidateQueries({ queryKey: QueryKeys.accounts.checkFavorite(...) }) so the
correct cache entry is refreshed.

@feruzmferuzm added the patch Bug fixes and patches (1.0.0 → 1.0.1) label Feb 22, 2026
@feruzm
feruzm merged commit fc9ff5d into developFeb 22, 2026
1 check passed
@feruzm
feruzm deleted the myfav branch February 22, 2026 14:12
@coderabbitaicoderabbitaiBot mentioned this pull request Mar 5, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patchBug fixes and patches (1.0.0 → 1.0.1)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@feruzm