Skip to content

Refactor home view into FSD structure#53

Merged
nbsp1221 merged 2 commits intomainfrom
refactor/home-fsd
Sep 29, 2025
Merged

Refactor home view into FSD structure#53
nbsp1221 merged 2 commits intomainfrom
refactor/home-fsd

Conversation

@nbsp1221
Copy link
Owner

@nbsp1221 nbsp1221 commented Sep 29, 2025

Summary

  • migrate the home library route into a Feature-Sliced page and widget
  • move video UI pieces into entity/widget layers and remove legacy components
  • replace the old useVideoLibrary hook with a dedicated library view model

Testing

  • bun run lint:fix
  • bun run test
  • bun run typecheck
  • bun run build

Summary by CodeRabbit

  • New Features

    • New Home page that renders the library with search, tag filters, pending count, totals, and a quick-view modal.
    • New LibraryView component and view hook powering filtered videos, modal state, and actions for search, tag toggles, edit/update, and delete.
  • Refactor

    • Simplified route/data flow to use the new Home page and centralized view logic.
    • Cleaned up modal and tag interaction flows for a more consistent UI.

@coderabbitai
Copy link

coderabbitai bot commented Sep 29, 2025

Walkthrough

Adds a Library View feature: new useLibraryView hook and LibraryView UI, a HomePage component and route refactor to render HomePage; removes the legacy useVideoLibrary hook; small event-parameter renames and an import path update.

Changes

Cohort / File(s) Summary
Library View model
app/widgets/library-view/model/useLibraryView.ts
Adds useLibraryView hook: manages videos, pendingVideos, searchFilters, modalState; provides handlers for search, tag toggle/clear, quick view, delete (DELETE /api/delete/{id}), update (PUT /api/update/{id}); exposes derived filteredVideos and counts; syncs with initial props.
Library View UI
app/widgets/library-view/ui/LibraryView.tsx, app/widgets/library-view/ui/VideoGrid.tsx, app/widgets/library-view/ui/VideoModal.tsx
Adds LibraryView component wiring header, TagFilter, VideoGrid, and VideoModal; VideoGrid import path changed to ~/entities/video/ui/VideoCard; VideoModal renames event params, inlines several handlers, and adjusts delete/update UI wiring.
Home page & route
app/pages/home/ui/HomePage.tsx, app/routes/_index.tsx
Adds HomePage component accepting videos, pendingVideos, initialFilters and initializing useLibraryView; refactors route to use loader data and render HomePage, removing prior inline UI/state and consolidating data flow.
Removed legacy hook
app/hooks/useVideoLibrary.ts
Deletes the legacy useVideoLibrary hook and its exported API surface (videos, pendingVideos, searchFilters, handlers, and helpers).
Entity UI minor edits
app/entities/video/ui/VideoCard.tsx
Renames event parameter eevent in internal handlers and updates usages (preventDefault/stopPropagation); no public API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Route as HomeRoute (loader)
  participant Page as HomePage
  participant Hook as useLibraryView
  participant View as LibraryView
  participant API as Backend API

  Route->>Page: render HomePage({ videos, pendingVideos })
  Page->>Hook: init({ initialVideos, initialPendingVideos, initialFilters })
  Hook-->>Page: state { filteredVideos, searchFilters, modalState, counts }
  Page->>View: render LibraryView(props from Hook)

  User->>View: Type in search box
  View->>Hook: handleSearchChange(query)
  Hook-->>View: filteredVideos updated

  User->>View: Click tag
  View->>Hook: handleTagToggle(tag)
  Hook-->>View: searchFilters.tags updated

  User->>View: Quick view video
  View->>Hook: handleQuickView(video)
  Hook-->>View: modalState open with video

  rect rgba(220,245,255,0.6)
  note right of View: Update flow
  User->>View: Save edits
  View->>Hook: handleUpdateVideo(id, payload)
  Hook->>API: PUT /api/update/{id}
  API-->>Hook: 200 OK
  Hook-->>View: videos updated, modal refreshed
  end

  rect rgba(255,235,235,0.6)
  note right of View: Delete flow
  User->>View: Confirm delete
  View->>Hook: handleDeleteVideo(id)
  Hook->>API: DELETE /api/delete/{id}
  API-->>Hook: 200 OK
  Hook-->>View: remove video, close modal if needed
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

In burrows of code I twitch and hop,
New hooks and views make old ones stop.
Tags click, modals peek, updates leap,
Deleted roots gently put to sleep.
Carrots compiled—my build’s a hop! 🥕

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 “Refactor home view into FSD structure” clearly and concisely conveys that the pull request’s primary change is migrating the home view into a Feature Sliced Design structure, matching the objectives of moving UI pieces into entity/widget layers and replacing the legacy hook with a dedicated view model.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/home-fsd

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 337abdc and 4a44d96.

📒 Files selected for processing (1)
  • app/widgets/library-view/model/useLibraryView.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/widgets/library-view/model/useLibraryView.ts

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 664058b and 771c886.

📒 Files selected for processing (8)
  • app/entities/video/ui/VideoCard.tsx (2 hunks)
  • app/hooks/useVideoLibrary.ts (0 hunks)
  • app/pages/home/ui/HomePage.tsx (1 hunks)
  • app/routes/_index.tsx (3 hunks)
  • app/widgets/library-view/model/useLibraryView.ts (1 hunks)
  • app/widgets/library-view/ui/LibraryView.tsx (1 hunks)
  • app/widgets/library-view/ui/VideoGrid.tsx (1 hunks)
  • app/widgets/library-view/ui/VideoModal.tsx (7 hunks)
💤 Files with no reviewable changes (1)
  • app/hooks/useVideoLibrary.ts
🧰 Additional context used
🧬 Code graph analysis (4)
app/pages/home/ui/HomePage.tsx (4)
app/types/video.ts (3)
  • Video (1-10)
  • PendingVideo (12-20)
  • SearchFilters (27-30)
app/widgets/library-view/model/useLibraryView.ts (1)
  • useLibraryView (43-153)
app/components/AppLayout.tsx (1)
  • AppLayout (30-42)
app/widgets/library-view/ui/LibraryView.tsx (1)
  • LibraryView (20-65)
app/widgets/library-view/model/useLibraryView.ts (1)
app/types/video.ts (3)
  • Video (1-10)
  • PendingVideo (12-20)
  • SearchFilters (27-30)
app/widgets/library-view/ui/LibraryView.tsx (5)
app/types/video.ts (2)
  • Video (1-10)
  • SearchFilters (27-30)
app/widgets/library-view/model/useLibraryView.ts (1)
  • ModalState (16-19)
app/widgets/library-view/ui/TagFilter.tsx (1)
  • TagFilter (11-51)
app/widgets/library-view/ui/VideoGrid.tsx (1)
  • VideoGrid (10-31)
app/widgets/library-view/ui/VideoModal.tsx (1)
  • VideoModal (28-233)
app/routes/_index.tsx (2)
app/types/video.ts (2)
  • Video (1-10)
  • PendingVideo (12-20)
app/pages/home/ui/HomePage.tsx (1)
  • HomePage (12-39)
🔇 Additional comments (2)
app/routes/_index.tsx (1)

34-41: Clean handoff to the Feature Page
Nice job delegating the route UI to HomePage and keeping the route focused on data loading—this lines up perfectly with the new FSD layering.

app/widgets/library-view/ui/LibraryView.tsx (1)

20-63: Well-structured widget composition
The LibraryView props/readability look solid: the header, filters, grid, and modal are cleanly wired, making the widget reusable and easy to follow.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 771c886 and 337abdc.

📒 Files selected for processing (8)
  • app/entities/video/ui/VideoCard.tsx (2 hunks)
  • app/hooks/useVideoLibrary.ts (0 hunks)
  • app/pages/home/ui/HomePage.tsx (1 hunks)
  • app/routes/_index.tsx (3 hunks)
  • app/widgets/library-view/model/useLibraryView.ts (1 hunks)
  • app/widgets/library-view/ui/LibraryView.tsx (1 hunks)
  • app/widgets/library-view/ui/VideoGrid.tsx (1 hunks)
  • app/widgets/library-view/ui/VideoModal.tsx (7 hunks)
💤 Files with no reviewable changes (1)
  • app/hooks/useVideoLibrary.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/entities/video/ui/VideoCard.tsx
🧰 Additional context used
🧬 Code graph analysis (4)
app/widgets/library-view/ui/LibraryView.tsx (5)
app/types/video.ts (2)
  • Video (1-10)
  • SearchFilters (27-30)
app/widgets/library-view/model/useLibraryView.ts (1)
  • ModalState (16-19)
app/widgets/library-view/ui/TagFilter.tsx (1)
  • TagFilter (11-51)
app/widgets/library-view/ui/VideoGrid.tsx (1)
  • VideoGrid (10-31)
app/widgets/library-view/ui/VideoModal.tsx (1)
  • VideoModal (28-233)
app/pages/home/ui/HomePage.tsx (4)
app/types/video.ts (3)
  • Video (1-10)
  • PendingVideo (12-20)
  • SearchFilters (27-30)
app/widgets/library-view/model/useLibraryView.ts (1)
  • useLibraryView (43-161)
app/components/AppLayout.tsx (1)
  • AppLayout (30-42)
app/widgets/library-view/ui/LibraryView.tsx (1)
  • LibraryView (20-65)
app/widgets/library-view/model/useLibraryView.ts (1)
app/types/video.ts (3)
  • Video (1-10)
  • PendingVideo (12-20)
  • SearchFilters (27-30)
app/routes/_index.tsx (2)
app/types/video.ts (2)
  • Video (1-10)
  • PendingVideo (12-20)
app/pages/home/ui/HomePage.tsx (1)
  • HomePage (12-39)

@nbsp1221 nbsp1221 merged commit 6cd5862 into main Sep 29, 2025
5 checks passed
@nbsp1221 nbsp1221 deleted the refactor/home-fsd branch September 29, 2025 07:43
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

Comments