Only show fav/reblog inaccurate count warning for remote posts

This commit is contained in:
Shadowfacts 2023-02-22 22:00:12 -05:00
parent 266868376d
commit 2582907919
4 changed files with 11 additions and 18 deletions

View File

@ -17,8 +17,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
private let actionType: StatusActionAccountListViewController.ActionType private let actionType: StatusActionAccountListViewController.ActionType
private let mastodonController: MastodonController private let mastodonController: MastodonController
/// If `true`, a warning will be shown below the account list describing that the total favs/reblogs may be innacurate. private var needsInaccurateCountWarning = false
var showInacurateCountWarning = false
var collectionView: UICollectionView! { var collectionView: UICollectionView! {
view as? UICollectionView view as? UICollectionView
@ -64,7 +63,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
switch dataSource.sectionIdentifier(for: sectionIndex)! { switch dataSource.sectionIdentifier(for: sectionIndex)! {
case .status: case .status:
var config = UICollectionLayoutListConfiguration(appearance: .grouped) var config = UICollectionLayoutListConfiguration(appearance: .grouped)
config.footerMode = self.showInacurateCountWarning ? .supplementary : .none config.footerMode = self.needsInaccurateCountWarning ? .supplementary : .none
config.backgroundColor = .appGroupedBackground config.backgroundColor = .appGroupedBackground
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.leadingSwipeActions() (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() loadViewIfNeeded()
needsInaccurateCountWarning = showInaccurateCountWarning && status.url?.host != mastodonController.instanceURL.host
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>() var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
snapshot.appendSections([.status, .accounts]) snapshot.appendSections([.status, .accounts])
snapshot.appendItems([.status(status.id, state)], toSection: .status) snapshot.appendItems([.status(status.id, state)], toSection: .status)

View File

@ -18,13 +18,7 @@ class StatusActionAccountListViewController: UIViewController {
private var accountIDs: [String]? private var accountIDs: [String]?
/// If `true`, a warning will be shown below the account list describing that the total favs/reblogs may be innacurate. /// If `true`, a warning will be shown below the account list describing that the total favs/reblogs may be innacurate.
var showInacurateCountWarning = false { var showInaccurateCountWarning = false
didSet {
if case .displaying(let vc) = state {
vc.showInacurateCountWarning = showInacurateCountWarning
}
}
}
private var state: State = .unloaded { private var state: State = .unloaded {
didSet { didSet {
@ -147,8 +141,7 @@ class StatusActionAccountListViewController: UIViewController {
private func statusLoaded(_ status: StatusMO) async { private func statusLoaded(_ status: StatusMO) async {
let vc = StatusActionAccountListCollectionViewController(statusID: statusID, actionType: actionType, mastodonController: mastodonController) let vc = StatusActionAccountListCollectionViewController(statusID: statusID, actionType: actionType, mastodonController: mastodonController)
vc.addStatus(status, state: statusState) vc.addStatus(status, state: statusState, showInaccurateCountWarning: showInaccurateCountWarning)
vc.showInacurateCountWarning = showInacurateCountWarning
if let accountIDs { if let accountIDs {
vc.setAccounts(accountIDs, animated: false) vc.setAccounts(accountIDs, animated: false)
} }

View File

@ -274,7 +274,7 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell {
fatalError() fatalError()
} }
let vc = StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController) let vc = StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController)
vc.showInacurateCountWarning = false vc.showInaccurateCountWarning = false
delegate.show(vc) delegate.show(vc)
} }
} }
@ -294,7 +294,7 @@ extension ActionNotificationGroupTableViewCell: MenuPreviewProvider {
fatalError() fatalError()
} }
let vc = StatusActionAccountListViewController(actionType: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController) let vc = StatusActionAccountListViewController(actionType: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController)
vc.showInacurateCountWarning = false vc.showInaccurateCountWarning = false
return vc return vc
}, actions: { }, actions: {
return [] return []

View File

@ -417,8 +417,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
return return
} }
let vc = StatusActionAccountListViewController(actionType: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController) 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.showInaccurateCountWarning = true
vc.showInacurateCountWarning = true
delegate.show(vc) delegate.show(vc)
} }
@ -427,7 +426,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
return return
} }
let vc = StatusActionAccountListViewController(actionType: .reblog, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController) let vc = StatusActionAccountListViewController(actionType: .reblog, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController)
vc.showInacurateCountWarning = true vc.showInaccurateCountWarning = true
delegate.show(vc) delegate.show(vc)
} }