refactor: extract useAsyncWindowOpen hook for async popup handling #20919

Closed
opened 2026-02-21 20:09:47 -05:00 by yindo · 0 comments
Owner

Originally created by @lyzno1 on GitHub (Dec 9, 2025).

Originally assigned to: @lyzno1 on GitHub.

Refactoring Opportunity

Multiple components implement the same placeholder window pattern for async popup opening. This should be extracted into a reusable hook.

Current Code Duplication

  1. billing-page/index.tsx (already correctly implemented)
  2. billing/pricing/plans/cloud-plan-item/index.tsx (needs fixing)
  3. apps/app-card.tsx (needs fixing)
  4. app/app-publisher/index.tsx (needs fixing)

Proposed Solution

Create useAsyncWindowOpen hook with:

  • Placeholder window creation in user gesture context
  • Async URL fetching
  • Window redirect or cleanup on error
  • Consistent error handling
  • TypeScript types

Benefits

  • Single source of truth for async popup logic
  • Consistent behavior across all components
  • Easier to maintain and test
  • Reusable for future scenarios
Originally created by @lyzno1 on GitHub (Dec 9, 2025). Originally assigned to: @lyzno1 on GitHub. ## Refactoring Opportunity Multiple components implement the same placeholder window pattern for async popup opening. This should be extracted into a reusable hook. ## Current Code Duplication 1. billing-page/index.tsx (already correctly implemented) 2. billing/pricing/plans/cloud-plan-item/index.tsx (needs fixing) 3. apps/app-card.tsx (needs fixing) 4. app/app-publisher/index.tsx (needs fixing) ## Proposed Solution Create useAsyncWindowOpen hook with: - Placeholder window creation in user gesture context - Async URL fetching - Window redirect or cleanup on error - Consistent error handling - TypeScript types ## Benefits - Single source of truth for async popup logic - Consistent behavior across all components - Easier to maintain and test - Reusable for future scenarios
yindo closed this issue 2026-02-21 20:09:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20919