From f17ef7b20e03c7bbf65c00e201d061aff2788335 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Tue, 22 Mar 2022 12:52:11 +0000 Subject: [PATCH 1/3] Prevent crash when searching for rooms --- Riot/Modules/DeepLink/UniversalLinkParameters.swift | 4 ++-- changelog.d/5883.bugfix | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelog.d/5883.bugfix diff --git a/Riot/Modules/DeepLink/UniversalLinkParameters.swift b/Riot/Modules/DeepLink/UniversalLinkParameters.swift index 611988232e..783cb7c2c4 100644 --- a/Riot/Modules/DeepLink/UniversalLinkParameters.swift +++ b/Riot/Modules/DeepLink/UniversalLinkParameters.swift @@ -23,7 +23,7 @@ class UniversalLinkParameters: NSObject { // MARK: - Properties /// The unprocessed the universal link URL - let universalLinkURL: URL + let universalLinkURL: URL? /// The fragment part of the universal link let fragment: String @@ -34,7 +34,7 @@ class UniversalLinkParameters: NSObject { // MARK: - Setup init(fragment: String, - universalLinkURL: URL, + universalLinkURL: URL?, presentationParameters: ScreenPresentationParameters) { self.fragment = fragment self.universalLinkURL = universalLinkURL diff --git a/changelog.d/5883.bugfix b/changelog.d/5883.bugfix new file mode 100644 index 0000000000..27400193c6 --- /dev/null +++ b/changelog.d/5883.bugfix @@ -0,0 +1,2 @@ +Search: prevent crash when searching for rooms + From f3aef51e0082f511d36799438e7d04b4991e7dfd Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Tue, 22 Mar 2022 12:55:41 +0000 Subject: [PATCH 2/3] Update comment --- Riot/Modules/DeepLink/UniversalLinkParameters.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Riot/Modules/DeepLink/UniversalLinkParameters.swift b/Riot/Modules/DeepLink/UniversalLinkParameters.swift index 783cb7c2c4..63fbf6a1e6 100644 --- a/Riot/Modules/DeepLink/UniversalLinkParameters.swift +++ b/Riot/Modules/DeepLink/UniversalLinkParameters.swift @@ -22,7 +22,7 @@ class UniversalLinkParameters: NSObject { // MARK: - Properties - /// The unprocessed the universal link URL + /// The unprocessed universal link URL let universalLinkURL: URL? /// The fragment part of the universal link From 413a1eb098c0c777a04a94a3e416aa0178cc4277 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Tue, 22 Mar 2022 14:46:27 +0000 Subject: [PATCH 3/3] Revert optionality and always pass url --- Riot/Modules/Application/LegacyAppDelegate.h | 8 -------- Riot/Modules/Application/LegacyAppDelegate.m | 6 ------ Riot/Modules/Common/Recents/RecentsViewController.m | 3 ++- Riot/Modules/Communities/Home/GroupHomeViewController.m | 2 +- Riot/Modules/DeepLink/UniversalLinkParameters.swift | 4 ++-- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Riot/Modules/Application/LegacyAppDelegate.h b/Riot/Modules/Application/LegacyAppDelegate.h index 40e3c23771..6875c7d0df 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.h +++ b/Riot/Modules/Application/LegacyAppDelegate.h @@ -227,14 +227,6 @@ UINavigationControllerDelegate // Reopen an existing direct room with this userId or creates a new one (if it doesn't exist) - (void)startDirectChatWithUserId:(NSString*)userId completion:(void (^)(void))completion; -/** - Process the fragment part of a vector.im link. - - @param fragment the fragment part of the universal link. - @return YES in case of processing success. - */ -- (BOOL)handleUniversalLinkFragment:(NSString*)fragment; - /** Process the fragment part of a vector.im link. diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 989ed7b959..49ea844c96 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -1263,12 +1263,6 @@ - (BOOL)handleUniversalLink:(NSUserActivity*)userActivity return [self handleUniversalLinkFragment:webURL.fragment fromURL:webURL]; } -- (BOOL)handleUniversalLinkFragment:(NSString*)fragment -{ - return [self handleUniversalLinkFragment:fragment fromURL:nil]; -} - - - (BOOL)handleUniversalLinkFragment:(NSString*)fragment fromURL:(NSURL*)universalLinkURL { diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 25aa17ec9e..0c731f7237 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -1564,7 +1564,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath { // Open the room or preview it NSString *fragment = [NSString stringWithFormat:@"/room/%@", [MXTools encodeURIComponent:roomIdOrAlias]]; - [[AppDelegate theDelegate] handleUniversalLinkFragment:fragment]; + NSURL *url = [NSURL URLWithString:[MXTools permalinkToRoom:fragment]]; + [[AppDelegate theDelegate] handleUniversalLinkFragment:fragment fromURL:url]; } [tableView deselectRowAtIndexPath:indexPath animated:NO]; } diff --git a/Riot/Modules/Communities/Home/GroupHomeViewController.m b/Riot/Modules/Communities/Home/GroupHomeViewController.m index e1d940a992..d8a9e3ed3a 100644 --- a/Riot/Modules/Communities/Home/GroupHomeViewController.m +++ b/Riot/Modules/Communities/Home/GroupHomeViewController.m @@ -890,7 +890,7 @@ - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRan // Open the group or preview it NSString *fragment = [NSString stringWithFormat:@"/group/%@", [MXTools encodeURIComponent:absoluteURLString]]; - [[AppDelegate theDelegate] handleUniversalLinkFragment:fragment]; + [[AppDelegate theDelegate] handleUniversalLinkFragment:fragment fromURL:URL]; } return shouldInteractWithURL; diff --git a/Riot/Modules/DeepLink/UniversalLinkParameters.swift b/Riot/Modules/DeepLink/UniversalLinkParameters.swift index 63fbf6a1e6..6ebe180eda 100644 --- a/Riot/Modules/DeepLink/UniversalLinkParameters.swift +++ b/Riot/Modules/DeepLink/UniversalLinkParameters.swift @@ -23,7 +23,7 @@ class UniversalLinkParameters: NSObject { // MARK: - Properties /// The unprocessed universal link URL - let universalLinkURL: URL? + let universalLinkURL: URL /// The fragment part of the universal link let fragment: String @@ -34,7 +34,7 @@ class UniversalLinkParameters: NSObject { // MARK: - Setup init(fragment: String, - universalLinkURL: URL?, + universalLinkURL: URL, presentationParameters: ScreenPresentationParameters) { self.fragment = fragment self.universalLinkURL = universalLinkURL