Ignore data detector URLs on file attachment names, always opening the file. (#6330)

This commit is contained in:
Doug
2022-06-22 15:40:19 +01:00
committed by GitHub
parent e071ec789a
commit 6d195c103d
2 changed files with 9 additions and 26 deletions
@@ -1562,6 +1562,14 @@ static NSMutableDictionary *childClasses;
associatedEvent = bubbleComponent.event;
}
// Tapping a file attachment who's name triggers a data detector will try to open that URL.
// Detect this and instead map the interaction into a tap on the cell.
if (associatedEvent.isMediaAttachment)
{
[delegate cell:self didRecognizeAction:kMXKRoomBubbleCellTapOnAttachmentView userInfo:nil];
return NO;
}
// Ask the delegate if iOS can open the link
shouldInteractWithURL = [self shouldInteractWithURL:URL urlItemInteraction:interaction associatedEvent:associatedEvent];
}
@@ -1569,32 +1577,6 @@ static NSMutableDictionary *childClasses;
return shouldInteractWithURL;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
// Delegate method only called on iOS 9. iOS 10+ use method above.
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
{
BOOL shouldInteractWithURL = YES;
if (delegate && URL)
{
MXEvent *associatedEvent;
if ([textView isMemberOfClass:[MXKMessageTextView class]])
{
MXKMessageTextView *mxkMessageTextView = (MXKMessageTextView *)textView;
MXKRoomBubbleComponent *bubbleComponent = [self closestBubbleComponentAtPosition:mxkMessageTextView.lastHitTestLocation];
associatedEvent = bubbleComponent.event;
}
// Ask the delegate if iOS can open the link
shouldInteractWithURL = [self shouldInteractWithURL:URL urlItemInteractionValue:@(0) associatedEvent:associatedEvent];
}
return shouldInteractWithURL;
}
#pragma clang diagnostic pop
#pragma mark - WKNavigationDelegate
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation