From 25829079194f6571990b6f4cc7aab42f4af0b9ec Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 22 Feb 2023 22:00:12 -0500 Subject: [PATCH] Only show fav/reblog inaccurate count warning for remote posts --- ...tusActionAccountListCollectionViewController.swift | 9 +++++---- .../StatusActionAccountListViewController.swift | 11 ++--------- .../ActionNotificationGroupTableViewCell.swift | 4 ++-- .../ConversationMainStatusCollectionViewCell.swift | 5 ++--- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Tusker/Screens/Status Action Account List/StatusActionAccountListCollectionViewController.swift b/Tusker/Screens/Status Action Account List/StatusActionAccountListCollectionViewController.swift index dc62d481..4826c37f 100644 --- a/Tusker/Screens/Status Action Account List/StatusActionAccountListCollectionViewController.swift +++ b/Tusker/Screens/Status Action Account List/StatusActionAccountListCollectionViewController.swift @@ -17,8 +17,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect private let actionType: StatusActionAccountListViewController.ActionType private let mastodonController: MastodonController - /// If `true`, a warning will be shown below the account list describing that the total favs/reblogs may be innacurate. - var showInacurateCountWarning = false + private var needsInaccurateCountWarning = false var collectionView: UICollectionView! { view as? UICollectionView @@ -64,7 +63,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect switch dataSource.sectionIdentifier(for: sectionIndex)! { case .status: var config = UICollectionLayoutListConfiguration(appearance: .grouped) - config.footerMode = self.showInacurateCountWarning ? .supplementary : .none + config.footerMode = self.needsInaccurateCountWarning ? .supplementary : .none config.backgroundColor = .appGroupedBackground config.leadingSwipeActionsConfigurationProvider = { [unowned self] in (collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.leadingSwipeActions() @@ -149,9 +148,11 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect } } - func addStatus(_ status: StatusMO, state: CollapseState) { + func addStatus(_ status: StatusMO, state: CollapseState, showInaccurateCountWarning: Bool) { loadViewIfNeeded() + needsInaccurateCountWarning = showInaccurateCountWarning && status.url?.host != mastodonController.instanceURL.host + var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([.status, .accounts]) snapshot.appendItems([.status(status.id, state)], toSection: .status) diff --git a/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift b/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift index c6fc7295..a1be1d32 100644 --- a/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift +++ b/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift @@ -18,13 +18,7 @@ class StatusActionAccountListViewController: UIViewController { private var accountIDs: [String]? /// If `true`, a warning will be shown below the account list describing that the total favs/reblogs may be innacurate. - var showInacurateCountWarning = false { - didSet { - if case .displaying(let vc) = state { - vc.showInacurateCountWarning = showInacurateCountWarning - } - } - } + var showInaccurateCountWarning = false private var state: State = .unloaded { didSet { @@ -147,8 +141,7 @@ class StatusActionAccountListViewController: UIViewController { private func statusLoaded(_ status: StatusMO) async { let vc = StatusActionAccountListCollectionViewController(statusID: statusID, actionType: actionType, mastodonController: mastodonController) - vc.addStatus(status, state: statusState) - vc.showInacurateCountWarning = showInacurateCountWarning + vc.addStatus(status, state: statusState, showInaccurateCountWarning: showInaccurateCountWarning) if let accountIDs { vc.setAccounts(accountIDs, animated: false) } diff --git a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift index ac1eb768..3cdbf24d 100644 --- a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift +++ b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift @@ -274,7 +274,7 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell { fatalError() } let vc = StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController) - vc.showInacurateCountWarning = false + vc.showInaccurateCountWarning = false delegate.show(vc) } } @@ -294,7 +294,7 @@ extension ActionNotificationGroupTableViewCell: MenuPreviewProvider { fatalError() } let vc = StatusActionAccountListViewController(actionType: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController) - vc.showInacurateCountWarning = false + vc.showInaccurateCountWarning = false return vc }, actions: { return [] diff --git a/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift b/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift index 93a6683a..7093c1ab 100644 --- a/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift @@ -417,8 +417,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status return } let vc = StatusActionAccountListViewController(actionType: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController) - // TODO: only show warning if the instance isn't the logged in one - vc.showInacurateCountWarning = true + vc.showInaccurateCountWarning = true delegate.show(vc) } @@ -427,7 +426,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status return } let vc = StatusActionAccountListViewController(actionType: .reblog, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController) - vc.showInacurateCountWarning = true + vc.showInaccurateCountWarning = true delegate.show(vc) }