mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Ignore data detector URLs on file attachment names, always opening the file. (#6330)
This commit is contained in:
parent
103fda27c5
commit
8927bff833
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
|
||||
|
|
1
changelog.d/6031.bugfix
Normal file
1
changelog.d/6031.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Timeline: When an attachment is named like an email address, open the file instead of Mail.app when tapped.
|
Loading…
Reference in a new issue