Widgets: Make sure we have a scalar token before opening one (#1723).

Make the build of the true widget URL asynchronous and build it only when necessary.
This commit is contained in:
manuroe
2018-01-04 11:49:39 +01:00
parent 78d19e7334
commit 83a51295aa
10 changed files with 125 additions and 82 deletions
@@ -66,8 +66,16 @@
mxkViewController.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
// Display the widget
WidgetViewController *widgetVC = [[WidgetViewController alloc] initForWidget:widget];
[mxkViewController.navigationController pushViewController:widgetVC animated:YES];
[widget widgetUrl:^(NSString * _Nonnull widgetUrl) {
WidgetViewController *widgetVC = [[WidgetViewController alloc] initWithUrl:widgetUrl forWidget:widget];
[mxkViewController.navigationController pushViewController:widgetVC animated:YES];
} failure:^(NSError * _Nonnull error) {
NSLog(@"[WidgetPickerVC] Cannot display widget %@", widget);
[[AppDelegate theDelegate] showErrorAsAlert:error];
}];
}];
[_alertController addAction:alertAction];
}