Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabsListManager refactor to have use cases #72

Merged
merged 26 commits into from
Feb 4, 2024

Conversation

kyzmitch
Copy link
Owner

@kyzmitch kyzmitch commented Jan 4, 2024

During Android development it was found that Android code base requires repositories and use cases to follow standard architecture, so that, there was no good example on iOS side to use it as a reference. So, it was decided to better first implement them on iOS side because it is easier and would allow to have good TabsDataService instead of not perfect TabsListManager which is only following observer pattern.

TabsListManager could potentially be split on:

  • ReadTabsUseCase
  • WriteTabsUseCase
  • SelectedTabUseCase

Search autocomplete and DNS resolving strategies are used only by the view models, so that, it makes sense to refactor them and rename to be the use cases as well:

  • AutocompleteSearchUseCase
  • ResolveDNSUseCase

and something which will allow to observe the tabs changes (existing Observer pattern).
Also, TabsListManager can be renamed to TabsDataService to have it in these use cases.

Remaining work:

  • there is an error in the logs related to web view state
finishLoading(_:_:) - failed to replace current tab: The operation couldn’t be completed. (CottonData.WebViewModelState.Error error 0.)

…ich is actually looks more like a data service partly. Also need to think how to separate observers from the use cases
@kyzmitch kyzmitch added enhancement iOS iOS client sources labels Jan 4, 2024
@kyzmitch kyzmitch force-pushed the feature/ios_tabs_use_cases branch 2 times, most recently from 6734fa4 to 226c23f Compare January 28, 2024 06:33
# Conflicts:
#	catowseriOS/CottonData/SearchViewModel/Autocomplete/WebSearchAutocomplete+AsyncAwait.swift
#	catowseriOS/CottonData/WebViewModel/DNSResolving/DNSResolver+AsyncAwait.swift
#	catowseriOS/catowser.xcodeproj/project.pbxproj
#	catowseriOS/catowser/BrowserContent/BrowserContentPreview.swift
#	catowseriOS/catowser/BrowserContent/WebView/WebViewModelV2.swift
#	catowseriOS/catowser/Extensions/TabsListManager+Extension.swift
…Phone layout. Fix web view model state by not calling load method if the initial state was pendingLoad in SwiftUI mode. Use Actor protocol for some interfaces which are only used by the actor. Logging.
…ated type is not supported by the SwiftMocky current version
@kyzmitch kyzmitch closed this Feb 4, 2024
@kyzmitch kyzmitch reopened this Feb 4, 2024
@kyzmitch kyzmitch closed this Feb 4, 2024
@kyzmitch kyzmitch reopened this Feb 4, 2024
@kyzmitch kyzmitch closed this Feb 4, 2024
@kyzmitch kyzmitch reopened this Feb 4, 2024
@kyzmitch kyzmitch closed this Feb 4, 2024
@kyzmitch kyzmitch reopened this Feb 4, 2024
@kyzmitch kyzmitch marked this pull request as ready for review February 4, 2024 15:29
@kyzmitch kyzmitch merged commit f0e3a91 into master Feb 4, 2024
4 checks passed
kyzmitch added a commit that referenced this pull request Mar 13, 2024
* Start work on tabs use cases to not have one big tabs list manager which is actually looks more like a data service partly. Also need to think how to separate observers from the use cases

* Finish ReadTabUseCase and UseCaseFactory, add service commands to TabsDataService

* Integrate more use cases and create new view models to leverage them

* Fix compilation

* Fix compilation of CoreBrowser tests

* Fix use case locator crash

* Combine last 4 commits

* Solve complex use case type registration issue

* Rename use case classes

* Doc comments, attempt to fix SwiftUI site loading (web view model creation)

* Attempt to fix web view model creation

* Create web view model without a specific site to solve the async init issue

* Use different approach to be able to store VM as a state object

* Use environment object to make the constructors smaller, also use normal search suggestions VM

* Update copyright header for the new files from this PR

* Fix content type reloading to the default one from the async task in Phone layout. Fix web view model state by not calling load method if the initial state was pendingLoad in SwiftUI mode. Use Actor protocol for some interfaces which are only used by the actor. Logging.

* Add mocks auto-generation for the use cases, currently primary associated type is not supported by the SwiftMocky current version

* Fix search suggestions vm tests compilation after adding use case

* Fix CottonData unit tests compilation

* Fix search suggestions view model tests

* Fix web view model tests

* Fix client compilation

* fix linter

* Swiftlint format result

* Fix lint errors for sure
@kyzmitch kyzmitch deleted the feature/ios_tabs_use_cases branch March 13, 2024 09:01
kyzmitch added a commit that referenced this pull request Mar 13, 2024
* Start work on tabs use cases to not have one big tabs list manager which is actually looks more like a data service partly. Also need to think how to separate observers from the use cases

* Finish ReadTabUseCase and UseCaseFactory, add service commands to TabsDataService

* Integrate more use cases and create new view models to leverage them

* Fix compilation

* Fix compilation of CoreBrowser tests

* Fix use case locator crash

* Combine last 4 commits

* Solve complex use case type registration issue

* Rename use case classes

* Doc comments, attempt to fix SwiftUI site loading (web view model creation)

* Attempt to fix web view model creation

* Create web view model without a specific site to solve the async init issue

* Use different approach to be able to store VM as a state object

* Use environment object to make the constructors smaller, also use normal search suggestions VM

* Update copyright header for the new files from this PR

* Fix content type reloading to the default one from the async task in Phone layout. Fix web view model state by not calling load method if the initial state was pendingLoad in SwiftUI mode. Use Actor protocol for some interfaces which are only used by the actor. Logging.

* Add mocks auto-generation for the use cases, currently primary associated type is not supported by the SwiftMocky current version

* Fix search suggestions vm tests compilation after adding use case

* Fix CottonData unit tests compilation

* Fix search suggestions view model tests

* Fix web view model tests

* Fix client compilation

* fix linter

* Swiftlint format result

* Fix lint errors for sure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement iOS iOS client sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant