From 35de31553e8d11e7b57fd8ea5c8bbcba5fd7e3d3 Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Mon, 5 Oct 2020 13:06:50 -0700 Subject: [PATCH] Renaming --- ...ListViewModel.swift => CollectionItemsViewModel.swift} | 8 ++++---- .../Sources/ViewModels/Entities/NavigationEvent.swift | 2 +- ViewModels/Sources/ViewModels/NavigationViewModel.swift | 4 ++-- ViewModels/Sources/ViewModels/ProfileViewModel.swift | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) rename ViewModels/Sources/ViewModels/{ListViewModel.swift => CollectionItemsViewModel.swift} (96%) diff --git a/ViewModels/Sources/ViewModels/ListViewModel.swift b/ViewModels/Sources/ViewModels/CollectionItemsViewModel.swift similarity index 96% rename from ViewModels/Sources/ViewModels/ListViewModel.swift rename to ViewModels/Sources/ViewModels/CollectionItemsViewModel.swift index 8a72a5b..849418a 100644 --- a/ViewModels/Sources/ViewModels/ListViewModel.swift +++ b/ViewModels/Sources/ViewModels/CollectionItemsViewModel.swift @@ -5,7 +5,7 @@ import Foundation import Mastodon import ServiceLayer -final public class ListViewModel: ObservableObject { +final public class CollectionItemsViewModel: ObservableObject { @Published public var alertItem: AlertItem? public private(set) var nextPageMaxID: String? public private(set) var maintainScrollPositionOfItem: CollectionItemIdentifier? @@ -33,7 +33,7 @@ final public class ListViewModel: ObservableObject { } } -extension ListViewModel: CollectionViewModel { +extension CollectionItemsViewModel: CollectionViewModel { public var sections: AnyPublisher<[[CollectionItemIdentifier]], Never> { items.map { $0.map { $0.map(CollectionItemIdentifier.init(item:)) } }.eraseToAnyPublisher() } @@ -64,7 +64,7 @@ extension ListViewModel: CollectionViewModel { case let .status(configuration): navigationEventsSubject.send( .collectionNavigation( - ListViewModel( + CollectionItemsViewModel( collectionService: collectionService .navigationService .contextService(id: configuration.status.displayStatus.id)))) @@ -134,7 +134,7 @@ extension ListViewModel: CollectionViewModel { } } -private extension ListViewModel { +private extension CollectionItemsViewModel { func cache(viewModel: CollectionItemViewModel, forItem item: CollectionItem) { viewModelCache[item] = (viewModel, viewModel.events.flatMap { $0.compactMap(NavigationEvent.init) } .assignErrorsToAlertItem(to: \.alertItem, on: self) diff --git a/ViewModels/Sources/ViewModels/Entities/NavigationEvent.swift b/ViewModels/Sources/ViewModels/Entities/NavigationEvent.swift index d8e52ee..b804457 100644 --- a/ViewModels/Sources/ViewModels/Entities/NavigationEvent.swift +++ b/ViewModels/Sources/ViewModels/Entities/NavigationEvent.swift @@ -21,7 +21,7 @@ extension NavigationEvent { case let .url(url): self = .urlNavigation(url) case let .collection(statusListService): - self = .collectionNavigation(ListViewModel(collectionService: statusListService)) + self = .collectionNavigation(CollectionItemsViewModel(collectionService: statusListService)) case let .profile(profileService): self = .profileNavigation(ProfileViewModel(profileService: profileService)) case .webfingerStart: diff --git a/ViewModels/Sources/ViewModels/NavigationViewModel.swift b/ViewModels/Sources/ViewModels/NavigationViewModel.swift index f003fff..9998db1 100644 --- a/ViewModels/Sources/ViewModels/NavigationViewModel.swift +++ b/ViewModels/Sources/ViewModels/NavigationViewModel.swift @@ -90,8 +90,8 @@ public extension NavigationViewModel { .store(in: &cancellables) } - func viewModel(timeline: Timeline) -> ListViewModel { - ListViewModel(collectionService: identification.service.service(timeline: timeline)) + func viewModel(timeline: Timeline) -> CollectionItemsViewModel { + CollectionItemsViewModel(collectionService: identification.service.service(timeline: timeline)) } } diff --git a/ViewModels/Sources/ViewModels/ProfileViewModel.swift b/ViewModels/Sources/ViewModels/ProfileViewModel.swift index 1c5868b..9e3434a 100644 --- a/ViewModels/Sources/ViewModels/ProfileViewModel.swift +++ b/ViewModels/Sources/ViewModels/ProfileViewModel.swift @@ -11,14 +11,14 @@ final public class ProfileViewModel { @Published public var alertItem: AlertItem? private let profileService: ProfileService - private let collectionViewModel: CurrentValueSubject + private let collectionViewModel: CurrentValueSubject private var cancellables = Set() init(profileService: ProfileService) { self.profileService = profileService collectionViewModel = CurrentValueSubject( - ListViewModel(collectionService: profileService.timelineService(profileCollection: .statuses))) + CollectionItemsViewModel(collectionService: profileService.timelineService(profileCollection: .statuses))) profileService.accountServicePublisher .map(AccountViewModel.init(accountService:)) @@ -27,7 +27,7 @@ final public class ProfileViewModel { $collection.dropFirst() .map(profileService.timelineService(profileCollection:)) - .map(ListViewModel.init(collectionService:)) + .map(CollectionItemsViewModel.init(collectionService:)) .sink { [weak self] in guard let self = self else { return }