2021-04-02 12:13:45 +02:00
|
|
|
//
|
|
|
|
// UserProvider.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-4-1.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Combine
|
|
|
|
import CoreData
|
|
|
|
import CoreDataStack
|
2021-04-30 08:55:02 +02:00
|
|
|
import UIKit
|
2021-04-02 12:13:45 +02:00
|
|
|
|
|
|
|
protocol UserProvider: NeedsDependency & DisposeBagCollectable & UIViewController {
|
|
|
|
// async
|
|
|
|
func mastodonUser() -> Future<MastodonUser?, Never>
|
2021-04-30 08:55:02 +02:00
|
|
|
|
2021-05-06 12:03:58 +02:00
|
|
|
func mastodonUser(for cell: UITableViewCell?) -> Future<MastodonUser?, Never>
|
2021-04-28 10:18:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extension UserProvider where Self: StatusProvider {
|
2021-05-06 12:03:58 +02:00
|
|
|
func mastodonUser(for cell: UITableViewCell?) -> Future<MastodonUser?, Never> {
|
2021-04-30 08:55:02 +02:00
|
|
|
Future { [weak self] promise in
|
2021-04-28 10:18:20 +02:00
|
|
|
guard let self = self else { return }
|
2021-05-06 12:03:58 +02:00
|
|
|
self.status(for: cell, indexPath: nil)
|
2021-04-28 10:18:20 +02:00
|
|
|
.sink { status in
|
2021-04-29 04:50:10 +02:00
|
|
|
promise(.success(status?.authorForUserProvider))
|
2021-04-28 10:18:20 +02:00
|
|
|
}
|
|
|
|
.store(in: &self.disposeBag)
|
|
|
|
}
|
|
|
|
}
|
2021-04-30 08:55:02 +02:00
|
|
|
|
2021-04-28 10:18:20 +02:00
|
|
|
func mastodonUser() -> Future<MastodonUser?, Never> {
|
2021-04-30 08:55:02 +02:00
|
|
|
Future { promise in
|
2021-04-28 10:18:20 +02:00
|
|
|
promise(.success(nil))
|
|
|
|
}
|
|
|
|
}
|
2021-04-02 12:13:45 +02:00
|
|
|
}
|