From 93e72e1cb617f15d2b7cc2a928472b2433485993 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 9 Sep 2024 23:53:37 -0400 Subject: [PATCH] Fix add saved hashtag search results selection not being cleared --- .../Explore/AddSavedHashtagViewController.swift | 10 ++++++++-- Tusker/Screens/Explore/ExploreViewController.swift | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Tusker/Screens/Explore/AddSavedHashtagViewController.swift b/Tusker/Screens/Explore/AddSavedHashtagViewController.swift index 1eb7134a..a0bcee2f 100644 --- a/Tusker/Screens/Explore/AddSavedHashtagViewController.swift +++ b/Tusker/Screens/Explore/AddSavedHashtagViewController.swift @@ -9,14 +9,14 @@ import UIKit import Pachyderm -class AddSavedHashtagViewController: UIViewController { +class AddSavedHashtagViewController: UIViewController, CollectionViewController { weak var mastodonController: MastodonController! var resultsController: SearchResultsViewController! var searchController: UISearchController! - private var collectionView: UICollectionView! + private(set) var collectionView: UICollectionView! private var dataSource: UICollectionViewDiffableDataSource! init(mastodonController: MastodonController) { @@ -91,6 +91,12 @@ class AddSavedHashtagViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + if searchController.isActive { + resultsController.clearSelectionOnAppear(animated: animated) + } + + clearSelectionOnAppear(animated: animated) + let request = Client.getTrendingHashtags(limit: 10) mastodonController.run(request) { (response) in var snapshot = NSDiffableDataSourceSnapshot() diff --git a/Tusker/Screens/Explore/ExploreViewController.swift b/Tusker/Screens/Explore/ExploreViewController.swift index b9ee9a09..44f76d95 100644 --- a/Tusker/Screens/Explore/ExploreViewController.swift +++ b/Tusker/Screens/Explore/ExploreViewController.swift @@ -96,7 +96,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect // so we manually propagate this down to the results controller // so that it can deselect on appear if searchController.isActive { - resultsController.viewWillAppear(animated) + resultsController.clearSelectionOnAppear(animated: animated) } clearSelectionOnAppear(animated: animated)