Don't cache state of follow menu action

Fixes #151
This commit is contained in:
Shadowfacts 2022-05-02 17:59:03 -04:00
parent 56a0518c80
commit 4a89ae3cfe
1 changed files with 11 additions and 1 deletions

View File

@ -59,7 +59,7 @@ extension MenuActionProvider {
draft.visibility = .direct
self.navigationDelegate?.compose(editing: draft)
}),
UIDeferredMenuElement({ (elementHandler) in
UIDeferredMenuElement.uncachedIfPossible({ (elementHandler) in
Task { @MainActor in
if let action = await self.followAction(for: accountID, mastodonController: mastodonController) {
elementHandler([action])
@ -339,3 +339,13 @@ extension SFSafariViewController: CustomPreviewPresenting {
presenter.present(self, animated: true)
}
}
private extension UIDeferredMenuElement {
static func uncachedIfPossible(_ elementProvider: @escaping (@escaping ([UIMenuElement]) -> Void) -> Void) -> UIDeferredMenuElement {
if #available(iOS 15.0, *) {
return UIDeferredMenuElement.uncached(elementProvider)
} else {
return UIDeferredMenuElement(elementProvider)
}
}
}