Merge pull request #684 from mastodon/fix-share-extension-reentry

Fix share extension reentry crash issue
This commit is contained in:
CMK 2022-11-24 18:05:40 +08:00 committed by GitHub
commit c17169bb6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -115,6 +115,10 @@ public class AppContext: ObservableObject {
.store(in: &disposeBag) .store(in: &disposeBag)
} }
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
}
} }
extension AppContext { extension AppContext {

View File

@ -21,7 +21,7 @@ final class ShareViewController: UIViewController {
var disposeBag = Set<AnyCancellable>() var disposeBag = Set<AnyCancellable>()
let context = AppContext() let context = AppContext.shared
private(set) lazy var viewModel = ShareViewModel(context: context) private(set) lazy var viewModel = ShareViewModel(context: context)
let publishButton: UIButton = { let publishButton: UIButton = {
@ -63,6 +63,10 @@ final class ShareViewController: UIViewController {
label.text = "No Available Account" // TODO: i18n label.text = "No Available Account" // TODO: i18n
return label return label
}() }()
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
}
} }
@ -155,7 +159,7 @@ extension ShareViewController {
_ = try await statusPublisher.publish(api: context.apiService, authContext: authContext) _ = try await statusPublisher.publish(api: context.apiService, authContext: authContext)
self.publishButton.setTitle(L10n.Common.Controls.Actions.done, for: .normal) self.publishButton.setTitle(L10n.Common.Controls.Actions.done, for: .normal)
try await Task.sleep(nanoseconds: 1 * .second) try await Task.sleep(nanoseconds: 1 * .second)
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil) self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
@ -325,3 +329,7 @@ extension ShareViewController {
case missingAuthentication case missingAuthentication
} }
} }
extension AppContext {
static let shared = AppContext()
}