Compare commits
No commits in common. "db7615d26f4c2382822b5c9b35b3476745e2b37e" and "948eff1f7e398f0659f263d4cb55c3d866d803f8" have entirely different histories.
db7615d26f
...
948eff1f7e
|
@ -20,7 +20,7 @@ public final class FollowedHashtag: NSManagedObject {
|
|||
|
||||
@nonobjc public class func fetchRequest(name: String) -> NSFetchRequest<FollowedHashtag> {
|
||||
let req = NSFetchRequest<FollowedHashtag>(entityName: "FollowedHashtag")
|
||||
req.predicate = NSPredicate(format: "name LIKE[cd] %@", name)
|
||||
req.predicate = NSPredicate(format: "name = %@", name)
|
||||
return req
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public final class SavedHashtag: NSManagedObject {
|
|||
|
||||
@nonobjc public class func fetchRequest(name: String) -> NSFetchRequest<SavedHashtag> {
|
||||
let req = NSFetchRequest<SavedHashtag>(entityName: "SavedHashtag")
|
||||
req.predicate = NSPredicate(format: "name LIKE[cd] %@", name)
|
||||
req.predicate = NSPredicate(format: "name = %@", name)
|
||||
return req
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,6 @@ class EditListAccountsViewController: EnhancedTableViewController {
|
|||
|
||||
navigationItem.searchController = searchController
|
||||
navigationItem.hidesSearchBarWhenScrolling = false
|
||||
if #available(iOS 16.0, *) {
|
||||
navigationItem.preferredSearchBarPlacement = .stacked
|
||||
}
|
||||
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("Rename", comment: "rename list button title"), style: .plain, target: self, action: #selector(renameButtonPressed))
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class ListTimelineViewController: TimelineViewController {
|
|||
super.viewDidAppear(animated)
|
||||
|
||||
if presentEditOnAppear {
|
||||
presentEdit(animated: true)
|
||||
presentEdit(animated: animated)
|
||||
presentEditOnAppear = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import Combine
|
|||
protocol MainSidebarViewControllerDelegate: AnyObject {
|
||||
func sidebarRequestPresentCompose(_ sidebarViewController: MainSidebarViewController)
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, didSelectItem item: MainSidebarViewController.Item)
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, showViewController viewController: UIViewController)
|
||||
}
|
||||
|
||||
class MainSidebarViewController: UIViewController {
|
||||
|
@ -209,18 +208,28 @@ class MainSidebarViewController: UIViewController {
|
|||
}
|
||||
|
||||
private func reloadLists(_ lists: [List]) {
|
||||
if let selectedItem,
|
||||
case .list(let list) = selectedItem,
|
||||
!lists.contains(where: { $0.id == list.id }) {
|
||||
returnToPreviousItem()
|
||||
}
|
||||
|
||||
var exploreSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||
exploreSnapshot.append([.listsHeader])
|
||||
exploreSnapshot.expand([.listsHeader])
|
||||
exploreSnapshot.append(lists.map { .list($0) }, to: .listsHeader)
|
||||
exploreSnapshot.append([.addList], to: .listsHeader)
|
||||
self.dataSource.apply(exploreSnapshot, to: .lists)
|
||||
var selectedItem: Item?
|
||||
if let selectedIndexPath = collectionView.indexPathsForSelectedItems?.first,
|
||||
let item = dataSource.itemIdentifier(for: selectedIndexPath) {
|
||||
if case .list(let list) = item,
|
||||
let newList = lists.first(where: { $0.id == list.id }) {
|
||||
selectedItem = .list(newList)
|
||||
} else {
|
||||
selectedItem = item
|
||||
}
|
||||
}
|
||||
|
||||
self.dataSource.apply(exploreSnapshot, to: .lists) {
|
||||
if let selectedItem,
|
||||
let indexPath = self.dataSource.indexPath(for: selectedItem) {
|
||||
self.collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredVertically)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
@ -246,39 +255,39 @@ class MainSidebarViewController: UIViewController {
|
|||
}
|
||||
|
||||
@objc private func reloadSavedHashtags() {
|
||||
let hashtags = fetchSavedHashtags().map {
|
||||
Item.savedHashtag(Hashtag(name: $0.name, url: $0.url))
|
||||
}
|
||||
if let selectedItem,
|
||||
case .savedHashtag(_) = selectedItem,
|
||||
!hashtags.contains(selectedItem) {
|
||||
returnToPreviousItem()
|
||||
}
|
||||
|
||||
let selected = collectionView.indexPathsForSelectedItems?.first
|
||||
|
||||
var hashtagsSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||
hashtagsSnapshot.append([.savedHashtagsHeader])
|
||||
hashtagsSnapshot.expand([.savedHashtagsHeader])
|
||||
let hashtags = fetchSavedHashtags().map {
|
||||
Item.savedHashtag(Hashtag(name: $0.name, url: $0.url))
|
||||
}
|
||||
hashtagsSnapshot.append(hashtags, to: .savedHashtagsHeader)
|
||||
hashtagsSnapshot.append([.addSavedHashtag], to: .savedHashtagsHeader)
|
||||
self.dataSource.apply(hashtagsSnapshot, to: .savedHashtags)
|
||||
self.dataSource.apply(hashtagsSnapshot, to: .savedHashtags, animatingDifferences: false) {
|
||||
if let selected = selected {
|
||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func reloadSavedInstances() {
|
||||
let instances = fetchSavedInstances().map {
|
||||
Item.savedInstance($0.url)
|
||||
}
|
||||
if let selectedItem,
|
||||
case .savedInstance(_) = selectedItem,
|
||||
!instances.contains(selectedItem) {
|
||||
returnToPreviousItem()
|
||||
}
|
||||
|
||||
let selected = collectionView.indexPathsForSelectedItems?.first
|
||||
|
||||
var instancesSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||
instancesSnapshot.append([.savedInstancesHeader])
|
||||
instancesSnapshot.expand([.savedInstancesHeader])
|
||||
let instances = fetchSavedInstances().map {
|
||||
Item.savedInstance($0.url)
|
||||
}
|
||||
instancesSnapshot.append(instances, to: .savedInstancesHeader)
|
||||
instancesSnapshot.append([.addSavedInstance], to: .savedInstancesHeader)
|
||||
self.dataSource.apply(instancesSnapshot, to: .savedInstances)
|
||||
self.dataSource.apply(instancesSnapshot, to: .savedInstances, animatingDifferences: false) {
|
||||
if let selected = selected {
|
||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func preferencesChanged() {
|
||||
|
@ -296,21 +305,11 @@ class MainSidebarViewController: UIViewController {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
private func returnToPreviousItem() {
|
||||
let item = previouslySelectedItem ?? .tab(.timelines)
|
||||
previouslySelectedItem = nil
|
||||
select(item: item, animated: true)
|
||||
sidebarDelegate?.sidebar(self, didSelectItem: item)
|
||||
}
|
||||
|
||||
private func showAddList() {
|
||||
let service = CreateListService(mastodonController: mastodonController, present: { self.present($0, animated: true
|
||||
) }) { list in
|
||||
self.select(item: .list(list), animated: false)
|
||||
let list = ListTimelineViewController(for: list, mastodonController: self.mastodonController)
|
||||
list.presentEditOnAppear = true
|
||||
self.sidebarDelegate?.sidebar(self, showViewController: list)
|
||||
self.sidebarDelegate?.sidebar(self, didSelectItem: .list(list))
|
||||
}
|
||||
service.run()
|
||||
}
|
||||
|
|
|
@ -358,13 +358,6 @@ extension MainSplitViewController: MainSidebarViewControllerDelegate {
|
|||
}
|
||||
select(item: item)
|
||||
}
|
||||
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, showViewController viewController: UIViewController) {
|
||||
if let previous = sidebar.previouslySelectedItem {
|
||||
navigationStacks[previous] = secondaryNavController.viewControllers
|
||||
}
|
||||
secondaryNavController.viewControllers = [viewController]
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate extension MainSidebarViewController.Item {
|
||||
|
|
Loading…
Reference in New Issue