mastodon-app-ufficiale-ipho.../Mastodon/Scene/Profile/Follower/FollowerListViewModel.swift

64 lines
1.6 KiB
Swift
Raw Normal View History

2021-11-01 12:54:07 +01:00
//
// FollowerListViewModel.swift
// Mastodon
//
// Created by Cirno MainasuK on 2021-11-1.
//
import Foundation
import Combine
import CoreData
import CoreDataStack
import GameplayKit
import MastodonSDK
2022-10-08 07:43:06 +02:00
import MastodonCore
2021-11-01 12:54:07 +01:00
final class FollowerListViewModel {
2021-11-01 12:54:07 +01:00
var disposeBag = Set<AnyCancellable>()
// input
let context: AppContext
let authContext: AuthContext
@Published var records = [Mastodon.Entity.Account]()
let listBatchFetchViewModel = ListBatchFetchViewModel()
@Published var accounts: [Mastodon.Entity.Account]
@Published var relationships: [Mastodon.Entity.Relationship]
@Published var domain: String?
@Published var userID: String?
let shouldFetch = PassthroughSubject<Void, Never>()
2023-10-25 18:03:46 +02:00
var tableView: UITableView?
2021-11-01 12:54:07 +01:00
// output
var diffableDataSource: UITableViewDiffableDataSource<UserSection, UserItem>?
private(set) lazy var stateMachine: GKStateMachine = {
let stateMachine = GKStateMachine(states: [
State.Initial(viewModel: self),
State.Reloading(viewModel: self),
State.Fail(viewModel: self),
State.Idle(viewModel: self),
State.Loading(viewModel: self),
State.NoMore(viewModel: self),
])
stateMachine.enter(State.Initial.self)
return stateMachine
}()
init(
context: AppContext,
authContext: AuthContext,
domain: String?,
userID: String?
) {
2021-11-01 12:54:07 +01:00
self.context = context
self.authContext = authContext
self.domain = domain
self.userID = userID
self.accounts = []
self.relationships = []
2021-11-01 12:54:07 +01:00
}
}