From e6a5b899bed54d0b401c0606ba6c0a5f85368165 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 11 Nov 2022 18:20:16 -0500 Subject: [PATCH] Add context menu action for deleting lists on iPad --- .../Screens/Main/MainSidebarViewController.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Main/MainSidebarViewController.swift b/Tusker/Screens/Main/MainSidebarViewController.swift index e015a13f..9cfe9f2c 100644 --- a/Tusker/Screens/Main/MainSidebarViewController.swift +++ b/Tusker/Screens/Main/MainSidebarViewController.swift @@ -554,11 +554,22 @@ extension MainSidebarViewController: UICollectionViewDelegate { } activity.displaysAuxiliaryScene = true return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { (_) in - return UIMenu(children: [ + var actions: [UIAction] = [ UIWindowScene.ActivationAction({ action in return UIWindowScene.ActivationConfiguration(userActivity: activity) }), - ]) + ] + + if case .list(let list) = item { + actions.append(UIAction(title: "Delete List", image: UIImage(systemName: "trash"), attributes: .destructive, handler: { [unowned self] _ in + Task { + let service = DeleteListService(list: list, mastodonController: self.mastodonController, present: { self.present($0, animated: true) }) + await service.run() + } + })) + } + + return UIMenu(children: actions) } } }