forked from shadowfacts/Tusker
Add New List action to Add to List menu
This commit is contained in:
parent
be3a61ebc7
commit
a4dbf3ddbb
|
@ -70,8 +70,8 @@ extension MenuActionProvider {
|
|||
accountID != ownAccount.id {
|
||||
actionsSection.append(relationshipAction(fetchRelationship, 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
|
||||
var listActions = mastodonController.lists.map { list in
|
||||
UIAction(title: list.title, image: UIImage(systemName: "list.bullet")) { [unowned self] _ in
|
||||
let req = List.add(list, accounts: [accountID])
|
||||
mastodonController.run(req) { response in
|
||||
if case .failure(let error) = response {
|
||||
|
@ -80,6 +80,21 @@ extension MenuActionProvider {
|
|||
}
|
||||
}
|
||||
}
|
||||
listActions.append(UIAction(title: "New List…", image: UIImage(systemName: "plus"), handler: { [unowned self] _ in
|
||||
Task { @MainActor in
|
||||
let service = CreateListService(mastodonController: mastodonController, present: { [unowned self] in
|
||||
self.navigationDelegate!.present($0, animated: true)
|
||||
}) { list 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
service.run()
|
||||
}
|
||||
}))
|
||||
elementHandler([UIMenu(title: "Add to List", image: UIImage(systemName: "list.bullet"), children: listActions)])
|
||||
}))
|
||||
suppressSection.append(relationshipAction(fetchRelationship, accountID: accountID, mastodonController: mastodonController, builder: { [unowned self] in self.blockAction(for: $0, mastodonController: $1) }))
|
||||
|
|
Loading…
Reference in New Issue