Renaming
This commit is contained in:
parent
2040c0dc6d
commit
35de31553e
|
@ -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)
|
|
@ -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:
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,14 +11,14 @@ final public class ProfileViewModel {
|
|||
@Published public var alertItem: AlertItem?
|
||||
|
||||
private let profileService: ProfileService
|
||||
private let collectionViewModel: CurrentValueSubject<ListViewModel, Never>
|
||||
private let collectionViewModel: CurrentValueSubject<CollectionItemsViewModel, Never>
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
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 }
|
||||
|
||||
|
|
Loading…
Reference in New Issue