Fixed a potential deadlock which could occur when typing

pull/1061/head
Morgan Pretty 1 month ago
parent 4dbe3b5c4c
commit 25b426235b

@ -303,6 +303,7 @@ final class InputView: UIView, InputViewButtonDelegate, InputTextViewDelegate, M
// Suggest that the user enable link previews if they haven't already and we haven't
// told them about link previews yet
let text = inputTextView.text!
DispatchQueue.global(qos: .userInitiated).async { [weak self, dependencies] in
let areLinkPreviewsEnabled: Bool = dependencies[singleton: .storage, key: .areLinkPreviewsEnabled]
if
@ -310,7 +311,9 @@ final class InputView: UIView, InputViewButtonDelegate, InputTextViewDelegate, M
!areLinkPreviewsEnabled &&
!dependencies[defaults: .standard, key: .hasSeenLinkPreviewSuggestion]
{
delegate?.showLinkPreviewSuggestionModal()
DispatchQueue.main.async {
self?.delegate?.showLinkPreviewSuggestionModal()
}
dependencies[defaults: .standard, key: .hasSeenLinkPreviewSuggestion] = true
return
}
@ -318,7 +321,10 @@ final class InputView: UIView, InputViewButtonDelegate, InputTextViewDelegate, M
guard areLinkPreviewsEnabled else { return }
// Proceed
autoGenerateLinkPreview()
DispatchQueue.main.async {
self?.autoGenerateLinkPreview()
}
}
}
func autoGenerateLinkPreview() {

Loading…
Cancel
Save