diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index e225169c6..b783eae17 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -634,6 +634,7 @@ "bug_report_send" = "Send"; // Widget +"widget_no_integrations_server_configured" = "No integrations server configured"; "widget_no_power_to_manage" = "You need permission to manage widgets in this room"; "widget_creation_failure" = "Widget creation has failed"; "widget_sticker_picker_no_stickerpacks_alert" = "You don't currently have any stickerpacks enabled."; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 8e7aa57b3..610984a56 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -2834,6 +2834,10 @@ internal enum VectorL10n { internal static var widgetIntegrationUnableToCreate: String { return VectorL10n.tr("Vector", "widget_integration_unable_to_create") } + /// No integrations server configured + internal static var widgetNoIntegrationsServerConfigured: String { + return VectorL10n.tr("Vector", "widget_no_integrations_server_configured") + } /// You need permission to manage widgets in this room internal static var widgetNoPowerToManage: String { return VectorL10n.tr("Vector", "widget_no_power_to_manage") diff --git a/Riot/Managers/Widgets/WidgetManager.h b/Riot/Managers/Widgets/WidgetManager.h index 7f94977f7..008a48c19 100644 --- a/Riot/Managers/Widgets/WidgetManager.h +++ b/Riot/Managers/Widgets/WidgetManager.h @@ -54,7 +54,8 @@ FOUNDATION_EXPORT NSString *const WidgetManagerErrorDomain; typedef enum : NSUInteger { WidgetManagerErrorCodeNotEnoughPower, - WidgetManagerErrorCodeCreationFailed + WidgetManagerErrorCodeCreationFailed, + WidgetManagerErrorCodeNoIntegrationsServerConfigured } WidgetManagerErrorCode; diff --git a/Riot/Managers/Widgets/WidgetManager.m b/Riot/Managers/Widgets/WidgetManager.m index 683559abc..d10c45995 100644 --- a/Riot/Managers/Widgets/WidgetManager.m +++ b/Riot/Managers/Widgets/WidgetManager.m @@ -264,7 +264,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; if (!config.hasUrls) { NSLog(@"[WidgetManager] createJitsiWidgetInRoom: Error: no Integrations Manager API URL for user %@", userId); - failure(nil); + failure(self.errorForNonConfiguredIntegrationManager); return nil; } @@ -517,7 +517,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; if (!config.hasUrls) { NSLog(@"[WidgetManager] registerForScalarToken: Error: no Integrations Manager API URL for user %@", mxSession.myUser.userId); - failure(nil); + failure(self.errorForNonConfiguredIntegrationManager); return nil; } @@ -580,7 +580,7 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; if (!config.hasUrls) { NSLog(@"[WidgetManager] validateScalarToken: Error: no Integrations Manager API URL for user %@", mxSession.myUser.userId); - failure(nil); + failure(self.errorForNonConfiguredIntegrationManager); return nil; } @@ -700,4 +700,14 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain"; forKey:@"integrationManagerConfigs"]; } + +#pragma mark - Errors + +- (NSError*)errorForNonConfiguredIntegrationManager +{ + return [NSError errorWithDomain:WidgetManagerErrorDomain + code:WidgetManagerErrorCodeNoIntegrationsServerConfigured + userInfo:@{NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"widget_no_integrations_server_configured", @"Vector", nil)}]; +} + @end diff --git a/Riot/Modules/Integrations/IntegrationManagerViewController.m b/Riot/Modules/Integrations/IntegrationManagerViewController.m index 3db2abbc9..ff9df08fe 100644 --- a/Riot/Modules/Integrations/IntegrationManagerViewController.m +++ b/Riot/Modules/Integrations/IntegrationManagerViewController.m @@ -18,6 +18,8 @@ #import "IntegrationManagerViewController.h" #import "WidgetManager.h" + +#import "AppDelegate.h" #import "Riot-Swift.h" NSString *const kIntegrationManagerMainScreen = nil; @@ -87,8 +89,14 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ"; } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); + NSLog(@"[IntegraionManagerVS] Cannot open due to missing scalar token. Error: %@", error); + self->operation = nil; [self stopActivityIndicator]; + + [self withdrawViewControllerAnimated:YES completion:^{ + [[AppDelegate theDelegate] showErrorAsAlert:error]; + }]; }]; } }