Skip to content

Commit

Permalink
Perform content validity checks on main queue.
Browse files Browse the repository at this point in the history
Using global background queue was handing the character counting work to a different thread every time the text changed. Forcing it always onto the same background queue would be another option, but main seems to feel fast enough and is safer because of all the view-related things downstream.

Contributes to #705 IOS client consistently hangs when writing new post at ~= 150 chars
  • Loading branch information
whattherestimefor committed Dec 16, 2024
1 parent eb5433e commit 9de3ae0
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ extension ComposeContentViewModel {
private func bind() {
// bind author
$authenticationBox
.receive(on: DispatchQueue.main)
.sink { [weak self] authenticationBox in
guard let self, let account = authenticationBox.cachedAccount else { return }

Expand All @@ -321,7 +322,7 @@ extension ComposeContentViewModel {

// bind text
$content
.receive(on: DispatchQueue.global(qos: .background))
.receive(on: DispatchQueue.main)
.map { [weak self] input in
guard let self, let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) else {
return input.count
Expand Down

0 comments on commit 9de3ae0

Please sign in to comment.