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 103fda27c5
commit 8927bff833
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 26 deletions

View file

@ -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

1
changelog.d/6031.bugfix Normal file
View file

@ -0,0 +1 @@
Timeline: When an attachment is named like an email address, open the file instead of Mail.app when tapped.