Run NSDataDetector link detection on background queue (IOS-285)
This commit is contained in:
parent
d84ca7bc75
commit
147c417a74
@ -324,6 +324,7 @@ extension ComposeContentViewModel {
|
||||
|
||||
// bind text
|
||||
$content
|
||||
.receive(on: DispatchQueue.global(qos: .background))
|
||||
.map { [weak self] input in
|
||||
guard let self, let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) else {
|
||||
return input.count
|
||||
@ -342,6 +343,7 @@ extension ComposeContentViewModel {
|
||||
.charactersReservedPerURL ?? MastodonAuthentication.fallbackCharactersReservedPerURL
|
||||
return lengthWithoutLinks + (matches.count * charactersReservedPerURL)
|
||||
}
|
||||
.receive(on: RunLoop.main)
|
||||
.assign(to: &$contentWeightedLength)
|
||||
|
||||
Publishers.CombineLatest(
|
||||
|
Loading…
x
Reference in New Issue
Block a user