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)
|
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?) {
|
private func doResolve(status: StatusMO) -> (Result, NSAttributedString?) {
|
||||||
if !hasSetup {
|
if !hasSetup {
|
||||||
setupFilters(filters: mastodonController.filters)
|
setupFilters(filters: mastodonController.filters)
|
||||||
|
|
|
@ -70,8 +70,11 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
||||||
if item.hideSeparators {
|
if item.hideSeparators {
|
||||||
config.topSeparatorVisibility = .hidden
|
config.topSeparatorVisibility = .hidden
|
||||||
config.bottomSeparatorVisibility = .hidden
|
config.bottomSeparatorVisibility = .hidden
|
||||||
}
|
} else if case .status(id: _, collapseState: _, filterState: let filterState, pinned: _) = item,
|
||||||
if case .status(_, _, _, _) = item {
|
filterer.isKnownHide(state: filterState) {
|
||||||
|
config.topSeparatorVisibility = .hidden
|
||||||
|
config.bottomSeparatorVisibility = .hidden
|
||||||
|
} else if case .status(_, _, _, _) = item {
|
||||||
config.topSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
|
config.topSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
|
||||||
config.bottomSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
|
config.bottomSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
|
||||||
}
|
}
|
||||||
|
@ -123,6 +126,8 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
||||||
cell.showPinned = item.4
|
cell.showPinned = item.4
|
||||||
cell.updateUI(statusID: item.0, state: item.1, filterResult: item.2, precomputedContent: item.3)
|
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
|
return UICollectionViewDiffableDataSource(collectionView: collectionView) { [unowned self] collectionView, indexPath, itemIdentifier in
|
||||||
switch itemIdentifier {
|
switch itemIdentifier {
|
||||||
case .header(let id):
|
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):
|
case .status(id: let id, collapseState: let collapseState, filterState: let filterState, pinned: let pinned):
|
||||||
let (result, precomputedContent) = filterResult(state: filterState, statusID: id)
|
let (result, precomputedContent) = filterResult(state: filterState, statusID: id)
|
||||||
|
switch result {
|
||||||
|
case .allow, .warn(_):
|
||||||
return collectionView.dequeueConfiguredReusableCell(using: statusCell, for: indexPath, item: (id, collapseState, result, precomputedContent, pinned))
|
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:
|
case .loadingIndicator:
|
||||||
return loadingIndicatorCell(for: indexPath)
|
return loadingIndicatorCell(for: indexPath)
|
||||||
case .confirmLoadMore:
|
case .confirmLoadMore:
|
||||||
|
|
|
@ -70,9 +70,8 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||||
if item.hideSeparators {
|
if item.hideSeparators {
|
||||||
config.topSeparatorVisibility = .hidden
|
config.topSeparatorVisibility = .hidden
|
||||||
config.bottomSeparatorVisibility = .hidden
|
config.bottomSeparatorVisibility = .hidden
|
||||||
} else if case .status(id: let id, collapseState: _, filterState: let filterState) = item,
|
} else if case .status(id: _, collapseState: _, filterState: let filterState) = item,
|
||||||
case (.hide, _) = filterResult(state: filterState, statusID: id) {
|
filterer.isKnownHide(state: filterState) {
|
||||||
// this runs after the cell is setup, so the filter state is already known and this check is cheap
|
|
||||||
config.topSeparatorVisibility = .hidden
|
config.topSeparatorVisibility = .hidden
|
||||||
config.bottomSeparatorVisibility = .hidden
|
config.bottomSeparatorVisibility = .hidden
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue