Compare commits
5 Commits
948eff1f7e
...
db7615d26f
Author | SHA1 | Date |
---|---|---|
Shadowfacts | db7615d26f | |
Shadowfacts | 2f0acad866 | |
Shadowfacts | a2b3fc0628 | |
Shadowfacts | e005b70071 | |
Shadowfacts | b515664db3 |
|
@ -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 = %@", name)
|
||||
req.predicate = NSPredicate(format: "name LIKE[cd] %@", 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 = %@", name)
|
||||
req.predicate = NSPredicate(format: "name LIKE[cd] %@", name)
|
||||
return req
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,9 @@ 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: animated)
|
||||
presentEdit(animated: true)
|
||||
presentEditOnAppear = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ 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 {
|
||||
|
@ -208,28 +209,18 @@ 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)
|
||||
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)
|
||||
}
|
||||
}
|
||||
self.dataSource.apply(exploreSnapshot, to: .lists)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
@ -255,39 +246,39 @@ class MainSidebarViewController: UIViewController {
|
|||
}
|
||||
|
||||
@objc private func reloadSavedHashtags() {
|
||||
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))
|
||||
}
|
||||
if let selectedItem,
|
||||
case .savedHashtag(_) = selectedItem,
|
||||
!hashtags.contains(selectedItem) {
|
||||
returnToPreviousItem()
|
||||
}
|
||||
|
||||
var hashtagsSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||
hashtagsSnapshot.append([.savedHashtagsHeader])
|
||||
hashtagsSnapshot.expand([.savedHashtagsHeader])
|
||||
hashtagsSnapshot.append(hashtags, to: .savedHashtagsHeader)
|
||||
hashtagsSnapshot.append([.addSavedHashtag], to: .savedHashtagsHeader)
|
||||
self.dataSource.apply(hashtagsSnapshot, to: .savedHashtags, animatingDifferences: false) {
|
||||
if let selected = selected {
|
||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
||||
}
|
||||
}
|
||||
self.dataSource.apply(hashtagsSnapshot, to: .savedHashtags)
|
||||
}
|
||||
|
||||
@objc private func reloadSavedInstances() {
|
||||
let selected = collectionView.indexPathsForSelectedItems?.first
|
||||
|
||||
var instancesSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||
instancesSnapshot.append([.savedInstancesHeader])
|
||||
instancesSnapshot.expand([.savedInstancesHeader])
|
||||
let instances = fetchSavedInstances().map {
|
||||
Item.savedInstance($0.url)
|
||||
}
|
||||
if let selectedItem,
|
||||
case .savedInstance(_) = selectedItem,
|
||||
!instances.contains(selectedItem) {
|
||||
returnToPreviousItem()
|
||||
}
|
||||
|
||||
var instancesSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||
instancesSnapshot.append([.savedInstancesHeader])
|
||||
instancesSnapshot.expand([.savedInstancesHeader])
|
||||
instancesSnapshot.append(instances, to: .savedInstancesHeader)
|
||||
instancesSnapshot.append([.addSavedInstance], to: .savedInstancesHeader)
|
||||
self.dataSource.apply(instancesSnapshot, to: .savedInstances, animatingDifferences: false) {
|
||||
if let selected = selected {
|
||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
||||
}
|
||||
}
|
||||
self.dataSource.apply(instancesSnapshot, to: .savedInstances)
|
||||
}
|
||||
|
||||
@objc private func preferencesChanged() {
|
||||
|
@ -305,11 +296,21 @@ 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.sidebarDelegate?.sidebar(self, didSelectItem: .list(list))
|
||||
self.select(item: .list(list), animated: false)
|
||||
let list = ListTimelineViewController(for: list, mastodonController: self.mastodonController)
|
||||
list.presentEditOnAppear = true
|
||||
self.sidebarDelegate?.sidebar(self, showViewController: list)
|
||||
}
|
||||
service.run()
|
||||
}
|
||||
|
|
|
@ -358,6 +358,13 @@ 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