forked from shadowfacts/Tusker
Fix hide filter action not working on profiles
This commit is contained in:
parent
54857a3bf3
commit
e3e55de55b
|
@ -131,6 +131,15 @@ class Filterer {
|
|||
state.state = .known(result, generation: generation)
|
||||
}
|
||||
|
||||
func isKnownHide(state: FilterState) -> Bool {
|
||||
switch state.state {
|
||||
case .known(.hide, generation: let gen) where gen >= generation:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
private func doResolve(status: StatusMO) -> (Result, NSAttributedString?) {
|
||||
if !hasSetup {
|
||||
setupFilters(filters: mastodonController.filters)
|
||||
|
|
|
@ -70,8 +70,11 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
if item.hideSeparators {
|
||||
config.topSeparatorVisibility = .hidden
|
||||
config.bottomSeparatorVisibility = .hidden
|
||||
}
|
||||
if case .status(_, _, _, _) = item {
|
||||
} else if case .status(id: _, collapseState: _, filterState: let filterState, pinned: _) = item,
|
||||
filterer.isKnownHide(state: filterState) {
|
||||
config.topSeparatorVisibility = .hidden
|
||||
config.bottomSeparatorVisibility = .hidden
|
||||
} else if case .status(_, _, _, _) = item {
|
||||
config.topSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
|
||||
config.bottomSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
|
||||
}
|
||||
|
@ -123,6 +126,8 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
cell.showPinned = item.4
|
||||
cell.updateUI(statusID: item.0, state: item.1, filterResult: item.2, precomputedContent: item.3)
|
||||
}
|
||||
let zeroHeightCell = UICollectionView.CellRegistration<ZeroHeightCollectionViewCell, Void> { _, _, _ in
|
||||
}
|
||||
return UICollectionViewDiffableDataSource(collectionView: collectionView) { [unowned self] collectionView, indexPath, itemIdentifier in
|
||||
switch itemIdentifier {
|
||||
case .header(let id):
|
||||
|
@ -149,7 +154,12 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
}
|
||||
case .status(id: let id, collapseState: let collapseState, filterState: let filterState, pinned: let pinned):
|
||||
let (result, precomputedContent) = filterResult(state: filterState, statusID: id)
|
||||
return collectionView.dequeueConfiguredReusableCell(using: statusCell, for: indexPath, item: (id, collapseState, result, precomputedContent, pinned))
|
||||
switch result {
|
||||
case .allow, .warn(_):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: statusCell, for: indexPath, item: (id, collapseState, result, precomputedContent, pinned))
|
||||
case .hide:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: zeroHeightCell, for: indexPath, item: ())
|
||||
}
|
||||
case .loadingIndicator:
|
||||
return loadingIndicatorCell(for: indexPath)
|
||||
case .confirmLoadMore:
|
||||
|
|
|
@ -70,9 +70,8 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
if item.hideSeparators {
|
||||
config.topSeparatorVisibility = .hidden
|
||||
config.bottomSeparatorVisibility = .hidden
|
||||
} else if case .status(id: let id, collapseState: _, filterState: let filterState) = item,
|
||||
case (.hide, _) = filterResult(state: filterState, statusID: id) {
|
||||
// this runs after the cell is setup, so the filter state is already known and this check is cheap
|
||||
} else if case .status(id: _, collapseState: _, filterState: let filterState) = item,
|
||||
filterer.isKnownHide(state: filterState) {
|
||||
config.topSeparatorVisibility = .hidden
|
||||
config.bottomSeparatorVisibility = .hidden
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue