fix: make report-status can be revealed
This commit is contained in:
parent
1356e3755f
commit
1b05d787df
|
@ -21,7 +21,7 @@ enum ReportSection: Equatable, Hashable {
|
|||
extension ReportSection {
|
||||
static func tableViewDiffableDataSource(
|
||||
for tableView: UITableView,
|
||||
dependency: NeedsDependency,
|
||||
dependency: ReportViewController,
|
||||
managedObjectContext: NSManagedObjectContext,
|
||||
timestampUpdatePublisher: AnyPublisher<Date, Never>
|
||||
) -> UITableViewDiffableDataSource<ReportSection, Item> {
|
||||
|
@ -33,6 +33,7 @@ extension ReportSection {
|
|||
switch item {
|
||||
case .reportStatus(let objectID, let attribute):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportedStatusTableViewCell.self), for: indexPath) as! ReportedStatusTableViewCell
|
||||
cell.dependency = dependency
|
||||
let activeMastodonAuthenticationBox = dependency.context.authenticationService.activeMastodonAuthenticationBox.value
|
||||
let requestUserID = activeMastodonAuthenticationBox?.userID ?? ""
|
||||
managedObjectContext.performAndWait {
|
||||
|
|
|
@ -498,6 +498,34 @@ extension StatusProviderFacade {
|
|||
.store(in: &dependency.context.disposeBag)
|
||||
}
|
||||
|
||||
static func responseToStatusContentWarningRevealAction(dependency: ReportViewController, cell: UITableViewCell) {
|
||||
let status = Future<Status?, Never> { promise in
|
||||
guard let diffableDataSource = dependency.viewModel.diffableDataSource,
|
||||
let indexPath = dependency.tableView.indexPath(for: cell),
|
||||
let item = diffableDataSource.itemIdentifier(for: indexPath) else {
|
||||
promise(.success(nil))
|
||||
return
|
||||
}
|
||||
let managedObjectContext = dependency.viewModel.statusFetchedResultsController
|
||||
.fetchedResultsController
|
||||
.managedObjectContext
|
||||
|
||||
switch item {
|
||||
case .reportStatus(let objectID, _):
|
||||
managedObjectContext.perform {
|
||||
let status = managedObjectContext.object(with: objectID) as! Status
|
||||
promise(.success(status))
|
||||
}
|
||||
default:
|
||||
promise(.success(nil))
|
||||
}
|
||||
}
|
||||
|
||||
_responseToStatusContentWarningRevealAction(
|
||||
dependency: dependency,
|
||||
status: status
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension StatusProviderFacade {
|
||||
|
|
|
@ -13,7 +13,7 @@ import CoreDataStack
|
|||
extension ReportViewModel {
|
||||
func setupDiffableDataSource(
|
||||
for tableView: UITableView,
|
||||
dependency: NeedsDependency
|
||||
dependency: ReportViewController
|
||||
) {
|
||||
let timestampUpdatePublisher = Timer.publish(every: 1.0, on: .main, in: .common)
|
||||
.autoconnect()
|
||||
|
|
|
@ -17,6 +17,7 @@ final class ReportedStatusTableViewCell: UITableViewCell, StatusCell {
|
|||
|
||||
static let bottomPaddingHeight: CGFloat = 10
|
||||
|
||||
var dependency: ReportViewController?
|
||||
var disposeBag = Set<AnyCancellable>()
|
||||
var pollCountdownSubscription: AnyCancellable?
|
||||
var observations = Set<NSKeyValueObservation>()
|
||||
|
@ -63,6 +64,9 @@ final class ReportedStatusTableViewCell: UITableViewCell, StatusCell {
|
|||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
// precondition: app is active
|
||||
guard UIApplication.shared.applicationState == .active else { return }
|
||||
DispatchQueue.main.async {
|
||||
self.statusView.drawContentWarningImageView()
|
||||
}
|
||||
|
@ -127,8 +131,10 @@ extension ReportedStatusTableViewCell {
|
|||
resetSeparatorLineLayout()
|
||||
|
||||
selectionStyle = .none
|
||||
statusView.delegate = self
|
||||
statusView.statusMosaicImageViewContainer.delegate = self
|
||||
statusView.actionToolbarContainer.isHidden = true
|
||||
statusView.isUserInteractionEnabled = false
|
||||
statusView.contentWarningOverlayView.blurContentImageView.backgroundColor = backgroundColor
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
|
@ -168,3 +174,44 @@ extension ReportedStatusTableViewCell {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ReportedStatusTableViewCell: MosaicImageViewContainerDelegate {
|
||||
func mosaicImageViewContainer(_ mosaicImageViewContainer: MosaicImageViewContainer, didTapImageView imageView: UIImageView, atIndex index: Int) {
|
||||
|
||||
}
|
||||
|
||||
func mosaicImageViewContainer(_ mosaicImageViewContainer: MosaicImageViewContainer, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView) {
|
||||
|
||||
guard let dependency = self.dependency else { return }
|
||||
StatusProviderFacade.responseToStatusContentWarningRevealAction(dependency: dependency, cell: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension ReportedStatusTableViewCell: StatusViewDelegate {
|
||||
func statusView(_ statusView: StatusView, headerInfoLabelDidPressed label: UILabel) {
|
||||
}
|
||||
|
||||
func statusView(_ statusView: StatusView, avatarButtonDidPressed button: UIButton) {
|
||||
}
|
||||
|
||||
func statusView(_ statusView: StatusView, revealContentWarningButtonDidPressed button: UIButton) {
|
||||
guard let dependency = self.dependency else { return }
|
||||
StatusProviderFacade.responseToStatusContentWarningRevealAction(dependency: dependency, cell: self)
|
||||
}
|
||||
|
||||
func statusView(_ statusView: StatusView, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView) {
|
||||
guard let dependency = self.dependency else { return }
|
||||
StatusProviderFacade.responseToStatusContentWarningRevealAction(dependency: dependency, cell: self)
|
||||
}
|
||||
|
||||
func statusView(_ statusView: StatusView, playerContainerView: PlayerContainerView, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView) {
|
||||
guard let dependency = self.dependency else { return }
|
||||
StatusProviderFacade.responseToStatusContentWarningRevealAction(dependency: dependency, cell: self)
|
||||
}
|
||||
|
||||
func statusView(_ statusView: StatusView, pollVoteButtonPressed button: UIButton) {
|
||||
}
|
||||
|
||||
func statusView(_ statusView: StatusView, activeLabel: ActiveLabel, didSelectActiveEntity entity: ActiveEntity) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue