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> {
|
@nonobjc public class func fetchRequest(name: String) -> NSFetchRequest<FollowedHashtag> {
|
||||||
let req = NSFetchRequest<FollowedHashtag>(entityName: "FollowedHashtag")
|
let req = NSFetchRequest<FollowedHashtag>(entityName: "FollowedHashtag")
|
||||||
req.predicate = NSPredicate(format: "name LIKE[cd] %@", name)
|
req.predicate = NSPredicate(format: "name = %@", name)
|
||||||
return req
|
return req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ public final class SavedHashtag: NSManagedObject {
|
||||||
|
|
||||||
@nonobjc public class func fetchRequest(name: String) -> NSFetchRequest<SavedHashtag> {
|
@nonobjc public class func fetchRequest(name: String) -> NSFetchRequest<SavedHashtag> {
|
||||||
let req = NSFetchRequest<SavedHashtag>(entityName: "SavedHashtag")
|
let req = NSFetchRequest<SavedHashtag>(entityName: "SavedHashtag")
|
||||||
req.predicate = NSPredicate(format: "name LIKE[cd] %@", name)
|
req.predicate = NSPredicate(format: "name = %@", name)
|
||||||
return req
|
return req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,6 @@ class EditListAccountsViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
navigationItem.searchController = searchController
|
navigationItem.searchController = searchController
|
||||||
navigationItem.hidesSearchBarWhenScrolling = false
|
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))
|
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)
|
super.viewDidAppear(animated)
|
||||||
|
|
||||||
if presentEditOnAppear {
|
if presentEditOnAppear {
|
||||||
presentEdit(animated: true)
|
presentEdit(animated: animated)
|
||||||
presentEditOnAppear = false
|
presentEditOnAppear = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import Combine
|
||||||
protocol MainSidebarViewControllerDelegate: AnyObject {
|
protocol MainSidebarViewControllerDelegate: AnyObject {
|
||||||
func sidebarRequestPresentCompose(_ sidebarViewController: MainSidebarViewController)
|
func sidebarRequestPresentCompose(_ sidebarViewController: MainSidebarViewController)
|
||||||
func sidebar(_ sidebarViewController: MainSidebarViewController, didSelectItem item: MainSidebarViewController.Item)
|
func sidebar(_ sidebarViewController: MainSidebarViewController, didSelectItem item: MainSidebarViewController.Item)
|
||||||
func sidebar(_ sidebarViewController: MainSidebarViewController, showViewController viewController: UIViewController)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainSidebarViewController: UIViewController {
|
class MainSidebarViewController: UIViewController {
|
||||||
|
@ -209,18 +208,28 @@ class MainSidebarViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func reloadLists(_ lists: [List]) {
|
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>()
|
var exploreSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||||
exploreSnapshot.append([.listsHeader])
|
exploreSnapshot.append([.listsHeader])
|
||||||
exploreSnapshot.expand([.listsHeader])
|
exploreSnapshot.expand([.listsHeader])
|
||||||
exploreSnapshot.append(lists.map { .list($0) }, to: .listsHeader)
|
exploreSnapshot.append(lists.map { .list($0) }, to: .listsHeader)
|
||||||
exploreSnapshot.append([.addList], 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
|
@MainActor
|
||||||
|
@ -246,39 +255,39 @@ class MainSidebarViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func reloadSavedHashtags() {
|
@objc private func reloadSavedHashtags() {
|
||||||
let hashtags = fetchSavedHashtags().map {
|
let selected = collectionView.indexPathsForSelectedItems?.first
|
||||||
Item.savedHashtag(Hashtag(name: $0.name, url: $0.url))
|
|
||||||
}
|
|
||||||
if let selectedItem,
|
|
||||||
case .savedHashtag(_) = selectedItem,
|
|
||||||
!hashtags.contains(selectedItem) {
|
|
||||||
returnToPreviousItem()
|
|
||||||
}
|
|
||||||
|
|
||||||
var hashtagsSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
var hashtagsSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||||
hashtagsSnapshot.append([.savedHashtagsHeader])
|
hashtagsSnapshot.append([.savedHashtagsHeader])
|
||||||
hashtagsSnapshot.expand([.savedHashtagsHeader])
|
hashtagsSnapshot.expand([.savedHashtagsHeader])
|
||||||
|
let hashtags = fetchSavedHashtags().map {
|
||||||
|
Item.savedHashtag(Hashtag(name: $0.name, url: $0.url))
|
||||||
|
}
|
||||||
hashtagsSnapshot.append(hashtags, to: .savedHashtagsHeader)
|
hashtagsSnapshot.append(hashtags, to: .savedHashtagsHeader)
|
||||||
hashtagsSnapshot.append([.addSavedHashtag], 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() {
|
@objc private func reloadSavedInstances() {
|
||||||
let instances = fetchSavedInstances().map {
|
let selected = collectionView.indexPathsForSelectedItems?.first
|
||||||
Item.savedInstance($0.url)
|
|
||||||
}
|
|
||||||
if let selectedItem,
|
|
||||||
case .savedInstance(_) = selectedItem,
|
|
||||||
!instances.contains(selectedItem) {
|
|
||||||
returnToPreviousItem()
|
|
||||||
}
|
|
||||||
|
|
||||||
var instancesSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
var instancesSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||||
instancesSnapshot.append([.savedInstancesHeader])
|
instancesSnapshot.append([.savedInstancesHeader])
|
||||||
instancesSnapshot.expand([.savedInstancesHeader])
|
instancesSnapshot.expand([.savedInstancesHeader])
|
||||||
|
let instances = fetchSavedInstances().map {
|
||||||
|
Item.savedInstance($0.url)
|
||||||
|
}
|
||||||
instancesSnapshot.append(instances, to: .savedInstancesHeader)
|
instancesSnapshot.append(instances, to: .savedInstancesHeader)
|
||||||
instancesSnapshot.append([.addSavedInstance], 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() {
|
@objc private func preferencesChanged() {
|
||||||
|
@ -297,20 +306,10 @@ class MainSidebarViewController: UIViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func returnToPreviousItem() {
|
|
||||||
let item = previouslySelectedItem ?? .tab(.timelines)
|
|
||||||
previouslySelectedItem = nil
|
|
||||||
select(item: item, animated: true)
|
|
||||||
sidebarDelegate?.sidebar(self, didSelectItem: item)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func showAddList() {
|
private func showAddList() {
|
||||||
let service = CreateListService(mastodonController: mastodonController, present: { self.present($0, animated: true
|
let service = CreateListService(mastodonController: mastodonController, present: { self.present($0, animated: true
|
||||||
) }) { list in
|
) }) { list in
|
||||||
self.select(item: .list(list), animated: false)
|
self.sidebarDelegate?.sidebar(self, didSelectItem: .list(list))
|
||||||
let list = ListTimelineViewController(for: list, mastodonController: self.mastodonController)
|
|
||||||
list.presentEditOnAppear = true
|
|
||||||
self.sidebarDelegate?.sidebar(self, showViewController: list)
|
|
||||||
}
|
}
|
||||||
service.run()
|
service.run()
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,13 +358,6 @@ extension MainSplitViewController: MainSidebarViewControllerDelegate {
|
||||||
}
|
}
|
||||||
select(item: item)
|
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 {
|
fileprivate extension MainSidebarViewController.Item {
|
||||||
|
|
Loading…
Reference in New Issue