Skip to content

fix: FilesViewModel - WPB-24805#4590

Open
WilhelmOks wants to merge 83 commits intodevelopfrom
improvement/WPB-24805-FilesViewModel-2
Open

fix: FilesViewModel - WPB-24805#4590
WilhelmOks wants to merge 83 commits intodevelopfrom
improvement/WPB-24805-FilesViewModel-2

Conversation

@WilhelmOks
Copy link
Copy Markdown
Collaborator

@WilhelmOks WilhelmOks commented Apr 20, 2026

TaskWPB-24805 [iOS] improve FilesViewModel of WireDrive

Issue

The swift file FilesViewModel is almost 1k loc long, is shared by multiple Views and has accumulated a lot of code for different kinds of functionality.
This makes it hard to read and maintain it.

Solution

Many different kinds of refactoring were implemented resulting in the FilesViewModel.swift file being about 50% smaller:

  • extracted FilesViewItem into a separate file
  • refactored SheetNavigation to use Model data instead of SwiftUI Views as payload, eliminating the need for import SwiftUI in ViewModel code
  • refactored sub-views and sheets to consistently use callbacks instead of Combine bindings to notify the parent view about specific events
  • unified creation of sub-views or sheets to only create the ViewModels rather than SwiftUI Views
  • extracted all functions which create ViewModels into the extension FilesViewModel+make_ViewModels.swift
  • extracted the big UseCases nested struct into the extension FilesViewModel+UseCases.swift
  • extracted the big function for loading offline files into LoadOfflineAvailableFilesUIAction
  • extracted logic related to loading paginated lists of (file) items into the components IncrementalListLoader and FilesListLoader
  • moved and grouped all of the remaining functions using // MARK: label comments

Testing

The logic should be exactly the same after the refactoring.

  • Go to the files list, via the Drive tab or the Shared Drive of a conversation
  • Check if the list is loaded correctly and the pagination is right
  • Check offline mode and if the list of offline available files is loaded correctly
  • Check deleting and restoring files via recycle bin

jullianm and others added 30 commits March 27, 2026 10:33
… Publisher with the need for manually setting up a sink
…WPB-23967-make-files-available-offline-ui-bl

# Conflicts:
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesItemViewModel.swift
…WPB-23967-make-files-available-offline-ui-bl

# Conflicts:
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/FilesContentView.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesItemViewModel.swift
…WPB-23967-make-files-available-offline-ui-bl
…WPB-23967-make-files-available-offline-ui-bl

# Conflicts:
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesItemViewModel.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesViewItemView.swift
…re and removing the accentColorProvider from all of the places where it's being passed around to ViewModels (because it's not needed)
# Conflicts:
#	WireMessaging/Sources/WireMessagingAssembly/WireMessagingFactory.swift
#	WireMessaging/Sources/WireMessagingDomain/WireDrive/UseCases/WireDriveMakeAssetAvailableOfflineUseCase.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/FilesContentView.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/FilesOfflineBarView.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/FilesPreviewHelpers.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/FilesViewContainer.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/FilesViewModel.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesItemView.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/RecycleBinContainer.swift
#	WireMessaging/Tests/WireMessagingTests/WireDrive/ImplementationTests/WireDriveLocalAssetRepositoryTests.swift
#	WireMessaging/Tests/WireMessagingTests/WireDrive/UITests/Components/Files/FilesViewModelTests.swift
@WilhelmOks WilhelmOks marked this pull request as ready for review May 5, 2026 14:41
@WilhelmOks WilhelmOks requested a review from OlivellaO May 5, 2026 14:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit a0bf1e7.

♻️ This comment has been updated with latest results.

Summary: workflow run #25441449176
Allure report (download zip): html-report-29784-improvement_WPB-24805-FilesViewModel-2

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown
Collaborator

@OlivellaO OlivellaO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants