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 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<Section, Item>()
snapshot.appendSections([.status, .accounts])
snapshot.appendItems([.status(status.id, state)], toSection: .status)

View File

@ -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)
}

View File

@ -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 []

View File

@ -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)
}