mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
2.6 KiB
2.6 KiB
Decomposition Plan for js/ui/components/VideoModal.js
Date: 2026-02-20
Agent: decompose-agent (via scheduler)
Target File: js/ui/components/VideoModal.js
Current Size: ~6000 lines (grandfathered)
Rationale
VideoModal.js is one of the largest files in the codebase. It handles too many responsibilities beyond just managing the modal lifecycle and video playback. Specifically, it contains extensive logic for:
- Zap Dialog Management: Handling the entire flow of zapping, including popover, form validation, receipts, and error handling.
- Link Previews: Fetching and rendering link previews for the video description.
Extracting these into dedicated controllers will significantly reduce the size of VideoModal.js and improve cohesion.
Extraction Plan
1. ZapController
Source: js/ui/components/VideoModal.js
Destination: js/ui/components/video-modal/zapController.js
Responsibilities:
- Manage the Zap dialog DOM elements (
modalZapDialog,modalZapForm, etc.). - Handle Zap interactions (open, close, submit).
- Render Zap receipts.
- Manage Zap visibility and state.
Methods to Move:
setupModalZapPopoveropenZapDialogcloseZapDialogisZapDialogOpenfocusZapAmountgetZapAmountValue,setZapAmountgetZapCommentValue,setZapCommentresetZapFormsetZapSplitSummarysetZapStatusclearZapReceipts,renderZapReceiptssetZapPending,setZapRetryPending,setZapCompletedapplyZapSendButtonStatesetZapVisibilitysetWalletPromptVisible
2. LinkPreviewController
Source: js/ui/components/VideoModal.js
Destination: js/ui/components/video-modal/linkPreviewController.js
Responsibilities:
- Manage link preview DOM elements (
videoDescriptionPreviews). - Fetch and render link previews.
- Handle link preview settings.
Methods to Move:
renderLinkPreviewsclearLinkPreviews,clearLinkPreviewRequestsextractDescriptionUrlsnormalizePreviewUrl,extractPreviewDomaincreateLinkPreviewCard,updateLinkPreviewCardsetLinkPreviewStatusresolveLinkPreviewhandleLinkPreviewSettingsChange
Implementation Details
VideoModalwill instantiate these controllers in its constructor.hydrate()will callcontroller.initialize().destroy()will callcontroller.destroy().VideoModalwill delegate relevant calls to these controllers.- Existing event listeners in
VideoModalthat trigger these actions will be updated to use the controllers.
Verification
npm run lintnpm run test:unit- Manual verification via code review (simulated).