Skip to content

Commit

Permalink
Proxy posting progess observer operation to main thread, per
Browse files Browse the repository at this point in the history
Pokeyman's wisdom. Should resolve iPad-mostly crash during posting.
  • Loading branch information
shaver committed Feb 17, 2024
1 parent 4d54ce5 commit 1b7e22a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions App/Posts/ReplyWorkspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,12 @@ final class ReplyWorkspace: NSObject {

var progressObservations: [NSKeyValueObservation] = []
let changeHandler: (Progress) -> Void = { progress in
if progress.fractionCompleted >= 1 || progress.isCancelled {
progressView?.stopBlock = nil
progressObservations.forEach { $0.invalidate() }
progressObservations.removeAll()
DispatchQueue.main.async {
if progress.fractionCompleted >= 1 || progress.isCancelled {
progressView?.stopBlock = nil
progressObservations.forEach { $0.invalidate() }
progressObservations.removeAll()
}
}
}
progressObservations.append(submitProgress.observe(\.isCancelled, options: []) { progress, change in
Expand Down

0 comments on commit 1b7e22a

Please sign in to comment.