chore: replace repository dependencies with use cases in Files view models - WPB-26913#4986
Open
jullianm wants to merge 4 commits into
Open
chore: replace repository dependencies with use cases in Files view models - WPB-26913#4986jullianm wants to merge 4 commits into
jullianm wants to merge 4 commits into
Conversation
jullianm
requested review from
a team,
David-Henner and
johnxnguyen
and removed request for
a team
July 9, 2026 07:48
Contributor
Test Results315 tests 315 ✅ 1m 47s ⏱️ Results for commit 12e3159. ♻️ This comment has been updated with latest results. Summary: workflow run #29003514028 |
|
johnxnguyen
reviewed
Jul 13, 2026
| return fileURL | ||
| } | ||
|
|
||
| @MainActor |
Collaborator
There was a problem hiding this comment.
question: why does this need to be main actor?
| package import Combine | ||
| package import Foundation | ||
|
|
||
| @MainActor |
Collaborator
There was a problem hiding this comment.
question: also why does this need to be main actor? I would expect that the view model is main actor but use cases are concurrent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue
FilesViewModel,FilesItemViewModel, and theMoveToFolderview models held direct references toWireDriveNodesRepositoryProtocol/WireDriveLocalAssetRepositoryProtocolalongside their use cases, and the use case wiring forFilesViewContainer,RecycleBinContainer, andWireMessagingFactorywas duplicated verbatim across all three call sites. This PR removes the repository dependencies from the view models so they only talk to use cases, and centralizes use case construction.Technical approach:
FilesViewModel.DependenciesandFilesViewModel.makeUseCases(dependencies:)to build the fullUseCasesstruct in one place, replacing the copy-pasted initializer previously duplicated inFilesViewContainer,RecycleBinContainer, andWireMessagingFactory.localAssetRepositoryandnodesRepositoryfromFilesViewModel; it now depends solely onUseCases.WireDriveFetchNodesPageUseCasenow receives itsconfigurationper call (invoke(configuration:...)) instead of at init, sinceFilesViewModelcomputes the configuration dynamically fromisBrowsing/isRecycleBin/navigationPath.WireDriveFetchNodesUseCaseis now@MainActor, exposes anodesCombine publisher (backed by its internalWireDriveNodesCollection), and adds aclearNodes()method to reset and restart observation — used byMoveToFolderPageViewModelinstead of owning its ownWireDriveNodesCollection.WireDriveObserveAssetUseCaseand a synchronousWireDriveGetAssetUseCase.asset(nodeID:), replacing directlocalAssetRepository.observeAsset/assetcalls inFilesItemViewModel.MoveToFolderViewModel/MoveToFolderPageViewModelnow take an injectedmoveNodeUseCase/fetchNodesUseCaseinstead of building their own repository-backed instances per navigation step.#if DEBUGdeleteAsset()helper inFilesItemViewModelthat reached into the repository directly.No behavior change intended; this is a dependency-direction cleanup ahead of further refactoring.
Testing
WireDriveFetchNodesPageUseCaseTests,FilesViewModelTests,FilesItemViewModelTests,FilesBrowserViewTests,FilesViewTests).WireMessagingtest target and manually exercise Files browsing, recycle bin, and Move to Folder flows to confirm listing, search, and offline-asset state still behave as before.Checklist
[WPB-XXX].UI accessibility checklist
No UI changes in this PR — internal dependency refactor only.