secana/Forji
3
55
Fork
You've already forked Forji
7

refactor: extract PullRequestDetailViewModel from the PR detail view #84

Open
systemblue wants to merge 1 commit from systemblue/Forji:feat/pr-detail-view-model into main
pull from: systemblue/Forji:feat/pr-detail-view-model
merge into: secana:main
secana:main
Contributor
Copy link

Extract the PR detail screen's logic into an @Observable PullRequestDetailViewModel, following the MVVM direction in CONTRIBUTING. The view dropped from ~576 lines to a thin renderer: it now owns layout and bindings while the view model owns loading, state, and actions.

What moved:

  • PullRequestDetailViewModel holds the load/refresh/action logic and state, talking to the API through narrow PullRequestDetailServiceProtocols so it is testable in isolation.
  • PullRequestDetailView+Sections.swift splits the section-building helpers out of the main view body.
  • PullRequestDetailViewModelTests cover the view model against the new service protocols.

Behavior-preserving refactor, no UI or API changes. Build and the ForjiTests unit suite pass (220 passing, 0 failing).

Extract the PR detail screen's logic into an `@Observable` `PullRequestDetailViewModel`, following the MVVM direction in CONTRIBUTING. The view dropped from ~576 lines to a thin renderer: it now owns layout and bindings while the view model owns loading, state, and actions. What moved: - `PullRequestDetailViewModel` holds the load/refresh/action logic and state, talking to the API through narrow `PullRequestDetailServiceProtocols` so it is testable in isolation. - `PullRequestDetailView+Sections.swift` splits the section-building helpers out of the main view body. - `PullRequestDetailViewModelTests` cover the view model against the new service protocols. Behavior-preserving refactor, no UI or API changes. Build and the `ForjiTests` unit suite pass (220 passing, 0 failing).
Second slice of the incremental MVVM migration proposed in #41, and the
first applied to one of the project's two largest views. PullRequestDetailView
drops from 612 lines to a 174-line binding layer plus a 244-line sections
extension. All state, derived properties, and async work move into a
@MainActor @Observable view model behind PullRequestServiceProtocol and
RepositoryServiceProtocol seams, so the view becomes a thin binding layer.
Behavior is unchanged, and the view model is covered by unit tests against
a fake service.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u feat/pr-detail-view-model:systemblue-feat/pr-detail-view-model
git switch systemblue-feat/pr-detail-view-model

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff systemblue-feat/pr-detail-view-model
git switch systemblue-feat/pr-detail-view-model
git rebase main
git switch main
git merge --ff-only systemblue-feat/pr-detail-view-model
git switch systemblue-feat/pr-detail-view-model
git rebase main
git switch main
git merge --no-ff systemblue-feat/pr-detail-view-model
git switch main
git merge --squash systemblue-feat/pr-detail-view-model
git switch main
git merge --ff-only systemblue-feat/pr-detail-view-model
git switch main
git merge systemblue-feat/pr-detail-view-model
git push origin main
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
secana/Forji!84
Reference in a new issue
secana/Forji
No description provided.
Delete branch "systemblue/Forji:feat/pr-detail-view-model"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?