Comfy-Org / Comfy-Org/ComfyUI_frontend

refactor: extract polling logic from SubscriptionRequiredDialogContent into useSubscriptionPolling composable

Open
#10,204 0 comments 0 reactions 1 assignee Claimed by @christian-byrne View on GitHub
developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

The script block in `src/platform/cloud/subscription/components/SubscriptionRequiredDialogContent.vue` currently mixes several concerns in a single scope:
- Subscription-status polling logic (interval management, poll attempts, start/stop helpers)
- Subscription-status watching
- Multiple event handlers
- UI state management

Extracting the polling logic into a dedicated composable (e.g., `useSubscriptionPolling`) would reduce cognitive complexity and improve testability.

## Proposed change

Create `src/platform/cloud/subscription/composables/useSubscriptionPolling.ts` that encapsulates:
- `POLL_INTERVAL_MS` and `MAX_POLL_ATTEMPTS` constants
- `startPolling()` / `stopPolling()` helpers
- Window focus listener wiring
- Automatic cleanup on unmount

Then replace the inline polling block in `SubscriptionRequiredDialogContent.vue` with a call to the new composable.

## Context

This was identified as pre-existing complexity (not introduced by PR #9901) during review of the two-stage team workspace upgrade flow feature.

Backlink: https://github.com/Comfy-Org/ComfyUI_frontend/pull/9901#discussion_r2945814485
Requested by: @christian-byrne

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10204-refactor-extract-polling-logic-from-SubscriptionRequiredDialogContent-into-useSubscr-3266d73d365081f49f95f24ae6001489) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.