diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index fd34c1cd4..37b768297 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -878,6 +878,10 @@ const CGFloat kMaxTextViewHeight = 98; [self ensureShouldShowVoiceMemoButtonAnimated:YES doLayout:YES]; [self updateHeightWithTextView:textView]; [self updateInputLinkPreview]; + + if (textView.text.ows_stripped.length < 1) { + [OWSLinkPreview clearLinkPreviewCache]; + } } - (void)textViewDidChangeSelection:(UITextView *)textView diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 0002ac339..614d73f7c 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2752,6 +2752,8 @@ typedef enum : NSUInteger { AudioServicesPlaySystemSound(soundId); } [self.typingIndicators didSendOutgoingMessageInThread:self.thread]; + + [OWSLinkPreview clearLinkPreviewCache]; } #pragma mark UIDocumentMenuDelegate diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 3806974b9..7ceb701b8 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -709,6 +709,8 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { [self.searchResultsController viewDidAppear:animated]; self.hasEverAppeared = YES; + + [OWSLinkPreview clearLinkPreviewCache]; } - (void)viewDidDisappear:(BOOL)animated diff --git a/SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift b/SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift index 9bb11b4de..86415b295 100644 --- a/SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift +++ b/SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift @@ -553,6 +553,13 @@ public class OWSLinkPreview: MTLModel { } } + @objc + public class func clearLinkPreviewCache() { + return serialQueue.async { + linkPreviewDraftCache.removeAllObjects() + } + } + @objc public class func tryToBuildPreviewInfoObjc(previewUrl: String?) -> AnyPromise { return AnyPromise(tryToBuildPreviewInfo(previewUrl: previewUrl))