fix: add selection state of report status

This commit is contained in:
ihugo 2021-04-23 09:37:18 +08:00
parent ce3f4f5e96
commit 008bb49d2d
10 changed files with 54 additions and 156 deletions

View File

@ -135,7 +135,6 @@
2DFAD5372617010500F9EE7C /* SearchingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DFAD5362617010500F9EE7C /* SearchingTableViewCell.swift */; }; 2DFAD5372617010500F9EE7C /* SearchingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DFAD5362617010500F9EE7C /* SearchingTableViewCell.swift */; };
5B24BBDA262DB14800A9381B /* ReportViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B24BBD7262DB14800A9381B /* ReportViewModel.swift */; }; 5B24BBDA262DB14800A9381B /* ReportViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B24BBD7262DB14800A9381B /* ReportViewModel.swift */; };
5B24BBDB262DB14800A9381B /* ReportViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B24BBD8262DB14800A9381B /* ReportViewModel+Diffable.swift */; }; 5B24BBDB262DB14800A9381B /* ReportViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B24BBD8262DB14800A9381B /* ReportViewModel+Diffable.swift */; };
5B24BBDC262DB14800A9381B /* ReportViewModel+Provider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B24BBD9262DB14800A9381B /* ReportViewModel+Provider.swift */; };
5B24BBE2262DB19100A9381B /* APIService+Report.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B24BBE1262DB19100A9381B /* APIService+Report.swift */; }; 5B24BBE2262DB19100A9381B /* APIService+Report.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B24BBE1262DB19100A9381B /* APIService+Report.swift */; };
5B8E055826319E47006E3C53 /* ReportFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B8E055726319E47006E3C53 /* ReportFooterView.swift */; }; 5B8E055826319E47006E3C53 /* ReportFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B8E055726319E47006E3C53 /* ReportFooterView.swift */; };
5B90C45E262599800002E742 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B90C456262599800002E742 /* SettingsViewModel.swift */; }; 5B90C45E262599800002E742 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B90C456262599800002E742 /* SettingsViewModel.swift */; };
@ -561,7 +560,6 @@
459EA4F43058CAB47719E963 /* Pods-Mastodon-MastodonUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon-MastodonUITests.debug.xcconfig"; path = "Target Support Files/Pods-Mastodon-MastodonUITests/Pods-Mastodon-MastodonUITests.debug.xcconfig"; sourceTree = "<group>"; }; 459EA4F43058CAB47719E963 /* Pods-Mastodon-MastodonUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon-MastodonUITests.debug.xcconfig"; path = "Target Support Files/Pods-Mastodon-MastodonUITests/Pods-Mastodon-MastodonUITests.debug.xcconfig"; sourceTree = "<group>"; };
5B24BBD7262DB14800A9381B /* ReportViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReportViewModel.swift; sourceTree = "<group>"; }; 5B24BBD7262DB14800A9381B /* ReportViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReportViewModel.swift; sourceTree = "<group>"; };
5B24BBD8262DB14800A9381B /* ReportViewModel+Diffable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ReportViewModel+Diffable.swift"; sourceTree = "<group>"; }; 5B24BBD8262DB14800A9381B /* ReportViewModel+Diffable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ReportViewModel+Diffable.swift"; sourceTree = "<group>"; };
5B24BBD9262DB14800A9381B /* ReportViewModel+Provider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ReportViewModel+Provider.swift"; sourceTree = "<group>"; };
5B24BBE1262DB19100A9381B /* APIService+Report.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "APIService+Report.swift"; sourceTree = "<group>"; }; 5B24BBE1262DB19100A9381B /* APIService+Report.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "APIService+Report.swift"; sourceTree = "<group>"; };
5B8E055726319E47006E3C53 /* ReportFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportFooterView.swift; sourceTree = "<group>"; }; 5B8E055726319E47006E3C53 /* ReportFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportFooterView.swift; sourceTree = "<group>"; };
5B90C456262599800002E742 /* SettingsViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; }; 5B90C456262599800002E742 /* SettingsViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; };
@ -1249,7 +1247,6 @@
children = ( children = (
5B24BBD7262DB14800A9381B /* ReportViewModel.swift */, 5B24BBD7262DB14800A9381B /* ReportViewModel.swift */,
5B24BBD8262DB14800A9381B /* ReportViewModel+Diffable.swift */, 5B24BBD8262DB14800A9381B /* ReportViewModel+Diffable.swift */,
5B24BBD9262DB14800A9381B /* ReportViewModel+Provider.swift */,
5BB04FEE262F0DCB0043BFF6 /* ReportViewModel+Data.swift */, 5BB04FEE262F0DCB0043BFF6 /* ReportViewModel+Data.swift */,
5BB04FD4262E7AFF0043BFF6 /* ReportViewController.swift */, 5BB04FD4262E7AFF0043BFF6 /* ReportViewController.swift */,
5BB04FDA262EA3070043BFF6 /* ReportHeaderView.swift */, 5BB04FDA262EA3070043BFF6 /* ReportHeaderView.swift */,
@ -2569,7 +2566,6 @@
2D76319F25C1521200929FB9 /* StatusSection.swift in Sources */, 2D76319F25C1521200929FB9 /* StatusSection.swift in Sources */,
DB35FC252612FD7A006193C9 /* ProfileFieldView.swift in Sources */, DB35FC252612FD7A006193C9 /* ProfileFieldView.swift in Sources */,
DB938F0326240EA300E5B6C1 /* CachedThreadViewModel.swift in Sources */, DB938F0326240EA300E5B6C1 /* CachedThreadViewModel.swift in Sources */,
5B24BBDC262DB14800A9381B /* ReportViewModel+Provider.swift in Sources */,
2D650FAB25ECDC9300851B58 /* Mastodon+Entity+Error+Detail.swift in Sources */, 2D650FAB25ECDC9300851B58 /* Mastodon+Entity+Error+Detail.swift in Sources */,
2D24E12D2626FD2E00A59D4F /* NotificationViewModel+LoadOldestState.swift in Sources */, 2D24E12D2626FD2E00A59D4F /* NotificationViewModel+LoadOldestState.swift in Sources */,
2DB72C8C262D764300CE6173 /* Mastodon+Entity+Notification+Type.swift in Sources */, 2DB72C8C262D764300CE6173 /* Mastodon+Entity+Notification+Type.swift in Sources */,

View File

@ -32,6 +32,9 @@ enum Item {
case bottomLoader case bottomLoader
case emptyStateHeader(attribute: EmptyStateHeaderAttribute) case emptyStateHeader(attribute: EmptyStateHeaderAttribute)
// reports
case reportStatus(objectID: NSManagedObjectID, attribute: ReportStatusAttribute)
} }
extension Item { extension Item {
@ -79,6 +82,15 @@ extension Item {
hasher.combine(id) hasher.combine(id)
} }
} }
class ReportStatusAttribute: StatusAttribute {
var isSelected: Bool
init(isSeparatorLineHidden: Bool = false, isSelected: Bool = false) {
self.isSelected = isSelected
super.init(isSeparatorLineHidden: isSeparatorLineHidden)
}
}
} }
extension Item: Equatable { extension Item: Equatable {
@ -106,6 +118,8 @@ extension Item: Equatable {
return true return true
case (.emptyStateHeader(let attributeLeft), .emptyStateHeader(let attributeRight)): case (.emptyStateHeader(let attributeLeft), .emptyStateHeader(let attributeRight)):
return attributeLeft == attributeRight return attributeLeft == attributeRight
case (.reportStatus(let objectIDLeft, _), .reportStatus(let objectIDRight, _)):
return objectIDLeft == objectIDRight
default: default:
return false return false
} }
@ -139,6 +153,8 @@ extension Item: Hashable {
hasher.combine(String(describing: Item.bottomLoader.self)) hasher.combine(String(describing: Item.bottomLoader.self))
case .emptyStateHeader(let attribute): case .emptyStateHeader(let attribute):
hasher.combine(attribute) hasher.combine(attribute)
case .reportStatus(let objectID, _):
hasher.combine(objectID)
} }
} }
} }

View File

@ -23,8 +23,7 @@ extension ReportSection {
for tableView: UITableView, for tableView: UITableView,
dependency: NeedsDependency, dependency: NeedsDependency,
managedObjectContext: NSManagedObjectContext, managedObjectContext: NSManagedObjectContext,
timestampUpdatePublisher: AnyPublisher<Date, Never>, timestampUpdatePublisher: AnyPublisher<Date, Never>
reportdStatusDelegate: ReportedStatusTableViewCellDelegate
) -> UITableViewDiffableDataSource<ReportSection, Item> { ) -> UITableViewDiffableDataSource<ReportSection, Item> {
UITableViewDiffableDataSource(tableView: tableView) {[ UITableViewDiffableDataSource(tableView: tableView) {[
weak dependency weak dependency
@ -32,7 +31,7 @@ extension ReportSection {
guard let dependency = dependency else { return UITableViewCell() } guard let dependency = dependency else { return UITableViewCell() }
switch item { switch item {
case .status(let objectID, let attribute): case .reportStatus(let objectID, let attribute):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportedStatusTableViewCell.self), for: indexPath) as! ReportedStatusTableViewCell let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportedStatusTableViewCell.self), for: indexPath) as! ReportedStatusTableViewCell
let activeMastodonAuthenticationBox = dependency.context.authenticationService.activeMastodonAuthenticationBox.value let activeMastodonAuthenticationBox = dependency.context.authenticationService.activeMastodonAuthenticationBox.value
let requestUserID = activeMastodonAuthenticationBox?.userID ?? "" let requestUserID = activeMastodonAuthenticationBox?.userID ?? ""
@ -49,8 +48,7 @@ extension ReportSection {
) )
} }
let isSelected = reportdStatusDelegate.reportedStatus(cell: cell, isSelected: indexPath) cell.setupSelected(attribute.isSelected)
cell.setupSelected(isSelected)
return cell return cell
default: default:
return nil return nil

View File

@ -125,6 +125,8 @@ extension StatusSection {
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineHeaderTableViewCell.self), for: indexPath) as! TimelineHeaderTableViewCell let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: TimelineHeaderTableViewCell.self), for: indexPath) as! TimelineHeaderTableViewCell
StatusSection.configureEmptyStateHeader(cell: cell, attribute: attribute) StatusSection.configureEmptyStateHeader(cell: cell, attribute: attribute)
return cell return cell
case .reportStatus:
return UITableViewCell()
} }
} }
} }

View File

@ -71,23 +71,24 @@ extension ReportViewModel {
diffableDataSource.apply(snapshot, animatingDifferences: !items.isEmpty) diffableDataSource.apply(snapshot, animatingDifferences: !items.isEmpty)
} }
var oldSnapshotAttributeDict: [NSManagedObjectID : Item.StatusAttribute] = [:] var oldSnapshotAttributeDict: [NSManagedObjectID : Item.ReportStatusAttribute] = [:]
let oldSnapshot = diffableDataSource.snapshot() let oldSnapshot = diffableDataSource.snapshot()
for item in oldSnapshot.itemIdentifiers { for item in oldSnapshot.itemIdentifiers {
guard case let .status(objectID, attribute) = item else { continue } guard case let .reportStatus(objectID, attribute) = item else { continue }
oldSnapshotAttributeDict[objectID] = attribute oldSnapshotAttributeDict[objectID] = attribute
} }
for objectID in objectIDs { for objectID in objectIDs {
let attribute = oldSnapshotAttributeDict[objectID] ?? Item.StatusAttribute() let attribute = oldSnapshotAttributeDict[objectID] ?? Item.ReportStatusAttribute()
let item = Item.status(objectID: objectID, attribute: attribute) let item = Item.reportStatus(objectID: objectID, attribute: attribute)
items.append(item) items.append(item)
guard let status = managedObjectContext.object(with: objectID) as? Status else { guard let status = managedObjectContext.object(with: objectID) as? Status else {
continue continue
} }
if status.id == self.statusId { if status.id == self.statusId {
self.selectedItems.append(item) attribute.isSelected = true
self.reportQuery.append(statusId: status.id)
self.continueEnableSubject.send(true) self.continueEnableSubject.send(true)
} }
} }

View File

@ -13,8 +13,7 @@ import CoreDataStack
extension ReportViewModel { extension ReportViewModel {
func setupDiffableDataSource( func setupDiffableDataSource(
for tableView: UITableView, for tableView: UITableView,
dependency: NeedsDependency, dependency: NeedsDependency
reportdStatusDelegate: ReportedStatusTableViewCellDelegate
) { ) {
let timestampUpdatePublisher = Timer.publish(every: 1.0, on: .main, in: .common) let timestampUpdatePublisher = Timer.publish(every: 1.0, on: .main, in: .common)
.autoconnect() .autoconnect()
@ -25,8 +24,7 @@ extension ReportViewModel {
for: tableView, for: tableView,
dependency: dependency, dependency: dependency,
managedObjectContext: statusFetchedResultsController.fetchedResultsController.managedObjectContext, managedObjectContext: statusFetchedResultsController.fetchedResultsController.managedObjectContext,
timestampUpdatePublisher: timestampUpdatePublisher, timestampUpdatePublisher: timestampUpdatePublisher
reportdStatusDelegate: reportdStatusDelegate
) )
// set empty section to make update animation top-to-bottom style // set empty section to make update animation top-to-bottom style

View File

@ -1,86 +0,0 @@
////
//// ReportViewModel+Provider.swift
//// Mastodon
////
//// Created by ihugo on 2021/4/19.
////
//
//import Combine
//import CoreData
//import CoreDataStack
//import Foundation
//import MastodonSDK
//import UIKit
//import os.log
//
//extension ReportViewController: StatusProvider {
// func status() -> Future<Status?, Never> {
// return Future { promise in promise(.success(nil)) }
// }
//
// func status(for cell: UITableViewCell?, indexPath: IndexPath?) -> Future<Status?, Never> {
// return Future { promise in
// guard let diffableDataSource = self.viewModel.diffableDataSource else {
// assertionFailure()
// promise(.success(nil))
// return
// }
// guard let indexPath = indexPath ?? cell.flatMap({ self.tableView.indexPath(for: $0) }),
// let item = diffableDataSource.itemIdentifier(for: indexPath) else {
// promise(.success(nil))
// return
// }
//
// switch item {
// case .status(let objectID, _):
// let managedObjectContext = self.viewModel.statusFetchedResultsController.fetchedResultsController.managedObjectContext
// managedObjectContext.perform {
// let status = managedObjectContext.object(with: objectID) as? Status
// promise(.success(status))
// }
// default:
// promise(.success(nil))
// }
// }
// }
//
// func status(for cell: UICollectionViewCell) -> Future<Status?, Never> {
// return Future { promise in promise(.success(nil)) }
// }
//
// var managedObjectContext: NSManagedObjectContext {
// return viewModel.statusFetchedResultsController.fetchedResultsController.managedObjectContext
// }
//
// var tableViewDiffableDataSource: UITableViewDiffableDataSource<StatusSection, Item>? {
// return viewModel.diffableDataSource
// }
//
// func item(for cell: UITableViewCell?, indexPath: IndexPath?) -> Item? {
// guard let diffableDataSource = self.viewModel.diffableDataSource else {
// assertionFailure()
// return nil
// }
//
// guard let indexPath = indexPath ?? cell.flatMap({ self.tableView.indexPath(for: $0) }),
// let item = diffableDataSource.itemIdentifier(for: indexPath) else {
// return nil
// }
//
// return item
// }
//
// func items(indexPaths: [IndexPath]) -> [Item] {
// guard let diffableDataSource = self.viewModel.diffableDataSource else {
// assertionFailure()
// return []
// }
//
// var items: [Item] = []
// for indexPath in indexPaths {
// guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { continue }
// items.append(item)
// }
// return items
// }
//}

View File

@ -26,8 +26,6 @@ class ReportViewModel: NSObject, NeedsDependency {
weak var coordinator: SceneCoordinator! { willSet { precondition(coordinator == nil) } } weak var coordinator: SceneCoordinator! { willSet { precondition(coordinator == nil) } }
var userId: String var userId: String
var statusId: String? var statusId: String?
var selectedItems = [Item]()
var comment: String?
var reportQuery: FileReportQuery var reportQuery: FileReportQuery
var disposeBag = Set<AnyCancellable>() var disposeBag = Set<AnyCancellable>()
@ -74,7 +72,7 @@ class ReportViewModel: NSObject, NeedsDependency {
self.reportQuery = FileReportQuery( self.reportQuery = FileReportQuery(
accountId: userId, accountId: userId,
statusIds: nil, statusIds: [],
comment: nil, comment: nil,
forward: nil forward: nil
) )
@ -90,8 +88,7 @@ class ReportViewModel: NSObject, NeedsDependency {
setupDiffableDataSource( setupDiffableDataSource(
for: input.tableView, for: input.tableView,
dependency: self, dependency: self
reportdStatusDelegate: self
) )
// data binding // data binding
@ -125,38 +122,31 @@ class ReportViewModel: NSObject, NeedsDependency {
func bindData(input: Input) { func bindData(input: Input) {
input.didToggleSelected.sink { [weak self] (item) in input.didToggleSelected.sink { [weak self] (item) in
guard let self = self else { return } guard let self = self else { return }
guard case let .status(objectID, attribute) = item else { return } guard case let .reportStatus(objectID, attribute) = item else { return }
guard var snapshot = self.diffableDataSource?.snapshot() else { return } guard var snapshot = self.diffableDataSource?.snapshot() else { return }
let managedObjectContext = self.statusFetchedResultsController.fetchedResultsController.managedObjectContext let managedObjectContext = self.statusFetchedResultsController.fetchedResultsController.managedObjectContext
guard let status = managedObjectContext.object(with: objectID) as? Status else { guard let status = managedObjectContext.object(with: objectID) as? Status else {
return return
} }
var items = [Item]() attribute.isSelected = !attribute.isSelected
if let index = self.selectedItems.firstIndex(of: item) { if attribute.isSelected {
self.selectedItems.remove(at: index) self.reportQuery.append(statusId: status.id)
items.append(.status(objectID: objectID, attribute: attribute))
if let index = self.reportQuery.statusIds?.firstIndex(of: status.id) {
self.reportQuery.statusIds?.remove(at: index)
}
} else { } else {
self.selectedItems.append(item) self.reportQuery.remove(statusId: status.id)
items.append(.status(objectID: objectID, attribute: attribute))
self.reportQuery.statusIds?.append(status.id)
} }
snapshot.reloadItems([item]) snapshot.reloadItems([item])
self.diffableDataSource?.apply(snapshot, animatingDifferences: false) self.diffableDataSource?.apply(snapshot, animatingDifferences: false)
let continueEnable = self.selectedItems.count > 0 let continueEnable = (self.reportQuery.statusIds?.count ?? 0) > 0
self.continueEnableSubject.send(continueEnable) self.continueEnableSubject.send(continueEnable)
} }
.store(in: &disposeBag) .store(in: &disposeBag)
input.comment.assign( input.comment.assign(
to: \.comment, to: \.comment,
on: self on: self.reportQuery
) )
.store(in: &disposeBag) .store(in: &disposeBag)
input.comment.sink { [weak self] (comment) in input.comment.sink { [weak self] (comment) in
@ -170,7 +160,7 @@ class ReportViewModel: NSObject, NeedsDependency {
func bindForStep1(input: Input) { func bindForStep1(input: Input) {
let skip = input.step1Skip.map { [weak self] value -> Void in let skip = input.step1Skip.map { [weak self] value -> Void in
guard let self = self else { return value } guard let self = self else { return value }
self.selectedItems.removeAll() self.reportQuery.statusIds?.removeAll()
return value return value
} }
@ -185,29 +175,13 @@ class ReportViewModel: NSObject, NeedsDependency {
func bindForStep2(input: Input, domain: String, activeMastodonAuthenticationBox: AuthenticationService.MastodonAuthenticationBox) { func bindForStep2(input: Input, domain: String, activeMastodonAuthenticationBox: AuthenticationService.MastodonAuthenticationBox) {
let skip = input.step2Skip.map { [weak self] value -> Void in let skip = input.step2Skip.map { [weak self] value -> Void in
guard let self = self else { return value } guard let self = self else { return value }
self.comment = nil self.reportQuery.comment = nil
return value return value
} }
Publishers.Merge(skip, input.step2Continue) Publishers.Merge(skip, input.step2Continue)
.sink { [weak self] _ in .sink { [weak self] _ in
guard let self = self else { return } guard let self = self else { return }
let managedObjectContext = self.statusFetchedResultsController.fetchedResultsController.managedObjectContext
self.reportQuery.comment = self.comment
var selectedStatusIds = [String]()
self.selectedItems.forEach { (item) in
guard case .status(let objectId, _) = item else {
return
}
guard let status = managedObjectContext.object(with: objectId) as? Status else {
return
}
selectedStatusIds.append(status.id)
}
self.reportQuery.statusIds = selectedStatusIds
self.context.apiService.report( self.context.apiService.report(
domain: domain, domain: domain,
query: self.reportQuery, query: self.reportQuery,
@ -237,13 +211,3 @@ class ReportViewModel: NSObject, NeedsDependency {
.store(in: &disposeBag) .store(in: &disposeBag)
} }
} }
extension ReportViewModel: ReportedStatusTableViewCellDelegate {
func reportedStatus(cell: ReportedStatusTableViewCell, isSelected indexPath: IndexPath) -> Bool {
guard let item = diffableDataSource?.itemIdentifier(for: indexPath) else {
return false
}
return selectedItems.contains(item)
}
}

View File

@ -13,15 +13,10 @@ import CoreData
import CoreDataStack import CoreDataStack
import ActiveLabel import ActiveLabel
protocol ReportedStatusTableViewCellDelegate: class {
func reportedStatus(cell: ReportedStatusTableViewCell, isSelected indexPath: IndexPath) -> Bool
}
final class ReportedStatusTableViewCell: UITableViewCell, StatusCell { final class ReportedStatusTableViewCell: UITableViewCell, StatusCell {
static let bottomPaddingHeight: CGFloat = 10 static let bottomPaddingHeight: CGFloat = 10
weak var delegate: ReportedStatusTableViewCellDelegate?
var disposeBag = Set<AnyCancellable>() var disposeBag = Set<AnyCancellable>()
var pollCountdownSubscription: AnyCancellable? var pollCountdownSubscription: AnyCancellable?
var observations = Set<NSKeyValueObservation>() var observations = Set<NSKeyValueObservation>()

View File

@ -75,5 +75,19 @@ public extension Mastodon.API.Reports {
self.comment = comment self.comment = comment
self.forward = forward self.forward = forward
} }
public func append(statusId: String) {
guard self.statusIds?.contains(statusId) != true else { return }
if self.statusIds == nil {
self.statusIds = []
}
self.statusIds?.append(statusId)
}
public func remove(statusId: String) {
guard let index = self.statusIds?.firstIndex(of: statusId) else { return }
self.statusIds?.remove(at: index)
}
} }
} }