diff --git a/CHANGES.rst b/CHANGES.rst index 4a6e35c30..50d4404b8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,7 @@ Bug fix: * Use white scroll bar on dark themes (#2158). * Registration: fix tap gesture on checkboxes in the terms screen. * Registration: improve validation UX on the terms screen (#2164). + * Infinite loading wheel when taping on a fake room alias (#679). Changes in 0.7.11 (2019-01-08) =============================================== diff --git a/Riot/AppDelegate.h b/Riot/AppDelegate.h index 2f04960be..811161010 100644 --- a/Riot/AppDelegate.h +++ b/Riot/AppDelegate.h @@ -90,6 +90,7 @@ extern NSString *const kAppDelegateNetworkStatusDidChangeNotification; - (void)restoreEmptyDetailsViewController; - (UIAlertController*)showErrorAsAlert:(NSError*)error; +- (UIAlertController*)showAlertWithTitle:(NSString*)title message:(NSString*)message; #pragma mark - Matrix Sessions handling diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index 0f6ccb1f4..3132f6db6 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -871,9 +871,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN return nil; } } - - [_errorNotification dismissViewControllerAnimated:NO completion:nil]; - + NSString *title = [error.userInfo valueForKey:NSLocalizedFailureReasonErrorKey]; NSString *msg = [error.userInfo valueForKey:NSLocalizedDescriptionKey]; if (!title) @@ -889,13 +887,26 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN } } - _errorNotification = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; + // Switch in offline mode in case of network reachability error + if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorNotConnectedToInternet) + { + self.isOffline = YES; + } + + return [self showAlertWithTitle:title message:msg]; +} + +- (UIAlertController*)showAlertWithTitle:(NSString*)title message:(NSString*)message +{ + [_errorNotification dismissViewControllerAnimated:NO completion:nil]; + + _errorNotification = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; [_errorNotification addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - + [AppDelegate theDelegate].errorNotification = nil; - + }]]; // Display the error notification if (!isErrorNotificationSuspended) @@ -903,13 +914,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN [_errorNotification mxk_setAccessibilityIdentifier:@"AppDelegateErrorAlert"]; [self showNotificationAlert:_errorNotification]; } - - // Switch in offline mode in case of network reachability error - if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorNotConnectedToInternet) - { - self.isOffline = YES; - } - + return self.errorNotification; } @@ -1917,6 +1922,12 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN } failure:^(NSError *error) { NSLog(@"[AppDelegate] Universal link: Error: The home server failed to resolve the room alias (%@)", roomIdOrAlias); + + [homeViewController stopActivityIndicator]; + + NSString *errorMessage = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_does_not_exist", @"Vector", nil), roomIdOrAlias]; + + [self showAlertWithTitle:nil message:errorMessage]; }]; } else if ([roomIdOrAlias hasPrefix:@"!"] && ((MXKAccount*)accountManager.activeAccounts.firstObject).mxSession.state != MXSessionStateRunning) @@ -3452,22 +3463,12 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN _jitsiViewController = nil; - NSError *theError = [NSError errorWithDomain:@"" - code:0 - userInfo:@{ - NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"call_jitsi_error", @"Vector", nil) - }]; - [self showErrorAsAlert:theError]; + [self showAlertWithTitle:nil message:NSLocalizedStringFromTable(@"call_jitsi_error", @"Vector", nil)]; }]; } else { - NSError *error = [NSError errorWithDomain:@"" - code:0 - userInfo:@{ - NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"call_already_displayed", @"Vector", nil) - }]; - [self showErrorAsAlert:error]; + [self showAlertWithTitle:nil message:NSLocalizedStringFromTable(@"call_already_displayed", @"Vector", nil)]; } } diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 7f168d5a6..f6ab41dfa 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -553,6 +553,7 @@ "do_not_ask_again" = "Do not ask again"; "camera_access_not_granted" = "%@ doesn't have permission to use Camera, please change privacy settings"; "large_badge_value_k_format" = "%.1fK"; +"room_does_not_exist" = "%@ does not exist"; // Call "call_incoming_voice_prompt" = "Incoming voice call from %@"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 1b1ab9bf4..ccdfdc3b3 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -614,6 +614,10 @@ internal enum VectorL10n { internal static let roomDirectoryNoPublicRoom = VectorL10n.tr("Vector", "room_directory_no_public_room") /// You do not have permission to post to this room internal static let roomDoNotHavePermissionToPost = VectorL10n.tr("Vector", "room_do_not_have_permission_to_post") + /// %@ does not exist + internal static func roomDoesNotExist(_ p1: String) -> String { + return VectorL10n.tr("Vector", "room_does_not_exist", p1) + } /// Reason for banning this user internal static let roomEventActionBanPromptReason = VectorL10n.tr("Vector", "room_event_action_ban_prompt_reason") /// Cancel Download