mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Various improvements
This commit is contained in:
@@ -506,7 +506,11 @@ func detectUrls(_ inputText: NSAttributedString?) -> [String] {
|
||||
return detectedUrls
|
||||
}
|
||||
|
||||
func urlPreviewStateForInputText(_ inputText: NSAttributedString?, context: AccountContext, currentQuery: String?) -> (String?, Signal<(TelegramMediaWebpage?) -> TelegramMediaWebpage?, NoError>)? {
|
||||
struct UrlPreviewState {
|
||||
var detectedUrl: String
|
||||
}
|
||||
|
||||
func urlPreviewStateForInputText(_ inputText: NSAttributedString?, context: AccountContext, currentQuery: UrlPreviewState?) -> (UrlPreviewState?, Signal<(TelegramMediaWebpage?) -> TelegramMediaWebpage?, NoError>)? {
|
||||
guard let _ = inputText else {
|
||||
if currentQuery != nil {
|
||||
return (nil, .single({ _ in return nil }))
|
||||
@@ -516,9 +520,9 @@ func urlPreviewStateForInputText(_ inputText: NSAttributedString?, context: Acco
|
||||
}
|
||||
if let _ = dataDetector {
|
||||
let detectedUrl = detectUrls(inputText).first
|
||||
if detectedUrl != currentQuery {
|
||||
if detectedUrl != currentQuery?.detectedUrl {
|
||||
if let detectedUrl = detectedUrl {
|
||||
return (detectedUrl, webpagePreview(account: context.account, url: detectedUrl)
|
||||
return (UrlPreviewState(detectedUrl: detectedUrl), webpagePreview(account: context.account, url: detectedUrl)
|
||||
|> mapToSignal { result -> Signal<TelegramMediaWebpage?, NoError> in
|
||||
guard case let .result(result) = result else {
|
||||
return .complete()
|
||||
|
||||
Reference in New Issue
Block a user