mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 15:22:39 +00:00
parent
98354f24aa
commit
3296a7561f
5 changed files with 48 additions and 2 deletions
|
@ -775,6 +775,7 @@
|
|||
"widget_integration_missing_room_id" = "Missing room_id in request.";
|
||||
"widget_integration_missing_user_id" = "Missing user_id in request.";
|
||||
"widget_integration_room_not_visible" = "Room %@ is not visible.";
|
||||
"widget_integration_manager_disabled" = "You need to enable Integration Manager in settings";
|
||||
|
||||
// Widget Picker
|
||||
"widget_picker_title" = "Integrations";
|
||||
|
|
|
@ -3262,6 +3262,10 @@ internal enum VectorL10n {
|
|||
internal static var widgetIntegrationFailedToSendRequest: String {
|
||||
return VectorL10n.tr("Vector", "widget_integration_failed_to_send_request")
|
||||
}
|
||||
/// You need to enable Integration Manager in settings
|
||||
internal static var widgetIntegrationManagerDisabled: String {
|
||||
return VectorL10n.tr("Vector", "widget_integration_manager_disabled")
|
||||
}
|
||||
/// Missing room_id in request.
|
||||
internal static var widgetIntegrationMissingRoomId: String {
|
||||
return VectorL10n.tr("Vector", "widget_integration_missing_room_id")
|
||||
|
|
|
@ -56,6 +56,7 @@ typedef enum : NSUInteger
|
|||
WidgetManagerErrorCodeNotEnoughPower,
|
||||
WidgetManagerErrorCodeCreationFailed,
|
||||
WidgetManagerErrorCodeNoIntegrationsServerConfigured,
|
||||
WidgetManagerErrorCodeDisabledIntegrationsServer,
|
||||
WidgetManagerErrorCodeFailedToConnectToIntegrationsServer,
|
||||
WidgetManagerErrorCodeTermsNotSigned
|
||||
}
|
||||
|
|
|
@ -269,6 +269,14 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
|
|||
return nil;
|
||||
}
|
||||
|
||||
RiotSharedSettings *sharedSettings = [[RiotSharedSettings alloc] initWithSession:room.mxSession];
|
||||
if (!sharedSettings.hasIntegrationProvisioningEnabled)
|
||||
{
|
||||
NSLog(@"[WidgetManager] createJitsiWidgetInRoom: Error: Disabled integration manager for user %@", userId);
|
||||
failure(self.errorForDisabledIntegrationManager);
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Build data for a jitsi widget
|
||||
NSString *widgetId = [NSString stringWithFormat:@"%@_%@_%@", kWidgetTypeJitsi, room.mxSession.myUser.userId, @((uint64_t)([[NSDate date] timeIntervalSince1970] * 1000))];
|
||||
|
||||
|
@ -791,4 +799,11 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
|
|||
userInfo:@{NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"widget_no_integrations_server_configured", @"Vector", nil)}];
|
||||
}
|
||||
|
||||
- (NSError*)errorForDisabledIntegrationManager
|
||||
{
|
||||
return [NSError errorWithDomain:WidgetManagerErrorDomain
|
||||
code:WidgetManagerErrorCodeDisabledIntegrationsServer
|
||||
userInfo:@{NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"widget_integration_manager_disabled", @"Vector", nil)}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -69,15 +69,22 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ";
|
|||
operation = nil;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidLoad];
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self loadData];
|
||||
}
|
||||
|
||||
- (void)loadData
|
||||
{
|
||||
RiotSharedSettings *sharedSettings = [[RiotSharedSettings alloc] initWithSession:mxSession];
|
||||
if (!sharedSettings.hasIntegrationProvisioningEnabled)
|
||||
{
|
||||
[self showDisabledIntegrationManagerError];
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self.URL && !operation)
|
||||
{
|
||||
[self startActivityIndicator];
|
||||
|
@ -706,6 +713,24 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ";
|
|||
}
|
||||
|
||||
|
||||
#pragma mark - Disabled Integrations
|
||||
|
||||
- (void)showDisabledIntegrationManagerError
|
||||
{
|
||||
NSString *message = NSLocalizedStringFromTable(@"widget_integration_manager_disabled", @"Vector", nil);
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
[alert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"]
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
[self withdrawViewControllerAnimated:YES completion:nil];
|
||||
}]];
|
||||
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Service terms
|
||||
|
||||
- (void)presentTerms
|
||||
|
|
Loading…
Reference in a new issue