Kurdtvs-Live-Kurdish-TV-Kur.../Mastodon/Protocol/UserProvider/UserProvider.swift

38 lines
993 B
Swift
Raw Normal View History

//
// 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
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>
}
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
guard let self = self else { return }
2021-05-06 12:03:58 +02:00
self.status(for: cell, indexPath: nil)
.sink { status in
2021-04-29 04:50:10 +02:00
promise(.success(status?.authorForUserProvider))
}
.store(in: &self.disposeBag)
}
}
2021-04-30 08:55:02 +02:00
func mastodonUser() -> Future<MastodonUser?, Never> {
2021-04-30 08:55:02 +02:00
Future { promise in
promise(.success(nil))
}
}
}