From bf87ae7a7d61f4467efddf872e9eec5772a98c58 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 19 Nov 2022 14:16:31 -0500 Subject: [PATCH] Add Add to List menu action to accounts Closes #247 --- Tusker/Screens/Utilities/Previewing.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tusker/Screens/Utilities/Previewing.swift b/Tusker/Screens/Utilities/Previewing.swift index fe6ec91b..dcf5a9c8 100644 --- a/Tusker/Screens/Utilities/Previewing.swift +++ b/Tusker/Screens/Utilities/Previewing.swift @@ -69,6 +69,19 @@ extension MenuActionProvider { if let ownAccount = mastodonController.account, accountID != ownAccount.id { actionsSection.append(relationshipAction(accountID: accountID, mastodonController: mastodonController, builder: { [unowned self] in self.followAction(for: $0, mastodonController: $1) })) + actionsSection.append(UIDeferredMenuElement.uncached({ elementHandler in + let listActions = mastodonController.lists.map { list in + UIAction(title: list.title, image: UIImage(systemName: "plus")) { [unowned self] _ in + let req = List.add(list, accounts: [accountID]) + mastodonController.run(req) { response in + if case .failure(let error) = response { + self.handleError(error, title: "Error Adding to List") + } + } + } + } + elementHandler([UIMenu(title: "Add to List", image: UIImage(systemName: "list.bullet"), children: listActions)]) + })) suppressSection.append(relationshipAction(accountID: accountID, mastodonController: mastodonController, builder: { [unowned self] in self.blockAction(for: $0, mastodonController: $1) })) suppressSection.append(relationshipAction(accountID: accountID, mastodonController: mastodonController, builder: { [unowned self] in self.muteAction(for: $0, mastodonController: $1) })) }