From 41665b1060f517353bc128a1e3148f7bbd6b41b9 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 7 Sep 2023 18:04:08 -0400 Subject: [PATCH] Indicate that edit history may be incomplete for remote posts Closes #385 --- .../StatusEditHistoryViewController.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Tusker/Screens/Status Edit History/StatusEditHistoryViewController.swift b/Tusker/Screens/Status Edit History/StatusEditHistoryViewController.swift index 10321b49..10c957aa 100644 --- a/Tusker/Screens/Status Edit History/StatusEditHistoryViewController.swift +++ b/Tusker/Screens/Status Edit History/StatusEditHistoryViewController.swift @@ -48,6 +48,10 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle } return config } + if let status = mastodonController.persistentContainer.status(for: statusID), + status.url?.host != mastodonController.instanceURL.host { + config.footerMode = .supplementary + } let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment) if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { @@ -77,7 +81,7 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle let loadingCell = UICollectionView.CellRegistration { cell, indexPath, itemIdentifier in cell.indicator.startAnimating() } - return UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in + let dataSource = UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in switch itemIdentifier { case .edit(let edit, let state, index: let index): return collectionView.dequeueConfiguredReusableCell(using: editCell, for: indexPath, item: (edit, state, index)) @@ -85,6 +89,15 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle return collectionView.dequeueConfiguredReusableCell(using: loadingCell, for: indexPath, item: ()) } } + let footerCell = UICollectionView.SupplementaryRegistration(elementKind: UICollectionView.elementKindSectionFooter) { supplementaryView, elementKind, indexPath in + var config = supplementaryView.defaultContentConfiguration() + config.text = "Edit history for posts originating from instances other than your own may not be complete." + supplementaryView.contentConfiguration = config + } + dataSource.supplementaryViewProvider = { collectionView, elementKind, indexPath in + return collectionView.dequeueConfiguredReusableSupplementary(using: footerCell, for: indexPath) + } + return dataSource } override func viewWillAppear(_ animated: Bool) {