mirror of
https://github.com/metabolist/metatext.git
synced 2024-06-25 00:20:47 +00:00
Renaming
This commit is contained in:
parent
2040c0dc6d
commit
35de31553e
|
@ -5,7 +5,7 @@ import Foundation
|
||||||
import Mastodon
|
import Mastodon
|
||||||
import ServiceLayer
|
import ServiceLayer
|
||||||
|
|
||||||
final public class ListViewModel: ObservableObject {
|
final public class CollectionItemsViewModel: ObservableObject {
|
||||||
@Published public var alertItem: AlertItem?
|
@Published public var alertItem: AlertItem?
|
||||||
public private(set) var nextPageMaxID: String?
|
public private(set) var nextPageMaxID: String?
|
||||||
public private(set) var maintainScrollPositionOfItem: CollectionItemIdentifier?
|
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> {
|
public var sections: AnyPublisher<[[CollectionItemIdentifier]], Never> {
|
||||||
items.map { $0.map { $0.map(CollectionItemIdentifier.init(item:)) } }.eraseToAnyPublisher()
|
items.map { $0.map { $0.map(CollectionItemIdentifier.init(item:)) } }.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ extension ListViewModel: CollectionViewModel {
|
||||||
case let .status(configuration):
|
case let .status(configuration):
|
||||||
navigationEventsSubject.send(
|
navigationEventsSubject.send(
|
||||||
.collectionNavigation(
|
.collectionNavigation(
|
||||||
ListViewModel(
|
CollectionItemsViewModel(
|
||||||
collectionService: collectionService
|
collectionService: collectionService
|
||||||
.navigationService
|
.navigationService
|
||||||
.contextService(id: configuration.status.displayStatus.id))))
|
.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) {
|
func cache(viewModel: CollectionItemViewModel, forItem item: CollectionItem) {
|
||||||
viewModelCache[item] = (viewModel, viewModel.events.flatMap { $0.compactMap(NavigationEvent.init) }
|
viewModelCache[item] = (viewModel, viewModel.events.flatMap { $0.compactMap(NavigationEvent.init) }
|
||||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
|
@ -21,7 +21,7 @@ extension NavigationEvent {
|
||||||
case let .url(url):
|
case let .url(url):
|
||||||
self = .urlNavigation(url)
|
self = .urlNavigation(url)
|
||||||
case let .collection(statusListService):
|
case let .collection(statusListService):
|
||||||
self = .collectionNavigation(ListViewModel(collectionService: statusListService))
|
self = .collectionNavigation(CollectionItemsViewModel(collectionService: statusListService))
|
||||||
case let .profile(profileService):
|
case let .profile(profileService):
|
||||||
self = .profileNavigation(ProfileViewModel(profileService: profileService))
|
self = .profileNavigation(ProfileViewModel(profileService: profileService))
|
||||||
case .webfingerStart:
|
case .webfingerStart:
|
||||||
|
|
|
@ -90,8 +90,8 @@ public extension NavigationViewModel {
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
func viewModel(timeline: Timeline) -> ListViewModel {
|
func viewModel(timeline: Timeline) -> CollectionItemsViewModel {
|
||||||
ListViewModel(collectionService: identification.service.service(timeline: timeline))
|
CollectionItemsViewModel(collectionService: identification.service.service(timeline: timeline))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,14 @@ final public class ProfileViewModel {
|
||||||
@Published public var alertItem: AlertItem?
|
@Published public var alertItem: AlertItem?
|
||||||
|
|
||||||
private let profileService: ProfileService
|
private let profileService: ProfileService
|
||||||
private let collectionViewModel: CurrentValueSubject<ListViewModel, Never>
|
private let collectionViewModel: CurrentValueSubject<CollectionItemsViewModel, Never>
|
||||||
private var cancellables = Set<AnyCancellable>()
|
private var cancellables = Set<AnyCancellable>()
|
||||||
|
|
||||||
init(profileService: ProfileService) {
|
init(profileService: ProfileService) {
|
||||||
self.profileService = profileService
|
self.profileService = profileService
|
||||||
|
|
||||||
collectionViewModel = CurrentValueSubject(
|
collectionViewModel = CurrentValueSubject(
|
||||||
ListViewModel(collectionService: profileService.timelineService(profileCollection: .statuses)))
|
CollectionItemsViewModel(collectionService: profileService.timelineService(profileCollection: .statuses)))
|
||||||
|
|
||||||
profileService.accountServicePublisher
|
profileService.accountServicePublisher
|
||||||
.map(AccountViewModel.init(accountService:))
|
.map(AccountViewModel.init(accountService:))
|
||||||
|
@ -27,7 +27,7 @@ final public class ProfileViewModel {
|
||||||
|
|
||||||
$collection.dropFirst()
|
$collection.dropFirst()
|
||||||
.map(profileService.timelineService(profileCollection:))
|
.map(profileService.timelineService(profileCollection:))
|
||||||
.map(ListViewModel.init(collectionService:))
|
.map(CollectionItemsViewModel.init(collectionService:))
|
||||||
.sink { [weak self] in
|
.sink { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue