Comfy-Org / Comfy-Org/ComfyUI_frontend

Refactor: Extract duplicated success handling in useUploadModelWizard

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

Description

## Context
In `src/platform/assets/composables/useUploadModelWizard.ts` around lines 236-268, the async and non-async upload branches duplicate the same success handling logic:

```typescript
uploadStatus.value = 'success'
await refreshModelCaches()
currentStep.value = 3
```

## Suggested Refactoring
Extract the repeated success handling into a helper function (e.g., `finalizeSuccessfulUpload()`) and call it from both branches:
- The async branch (after `assetService.uploadAssetAsync` returns a completed task)
- The non-async branch (after `assetService.uploadAssetFromUrl`)

This will reduce duplication and make future maintenance easier.

## References
- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/7746
- Comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/7746#discussion_r2663480086
- Requested by: @DrJKL

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-7861-Refactor-Extract-duplicated-success-handling-in-useUploadModelWizard-2e06d73d3650819a87effc96e9a188fc) 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.