MOBILE-3039 core: Wait a bit before displaying loading modal
parent
c76e7f3fcd
commit
455b78d98f
|
@ -167,7 +167,10 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler {
|
|||
Object.assign(params, { course: course });
|
||||
|
||||
if (navCtrl) {
|
||||
return navCtrl.push('CoreCourseSectionPage', params);
|
||||
// Don't return the .push promise, we don't want to display a loading modal during the page transition.
|
||||
navCtrl.push('CoreCourseSectionPage', params);
|
||||
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
// Open the course in the "phantom" tab.
|
||||
this.loginHelper = this.loginHelper || this.injector.get(CoreLoginHelperProvider);
|
||||
|
|
|
@ -1250,11 +1250,14 @@ export class CoreDomUtilsProvider {
|
|||
content: text
|
||||
}),
|
||||
dismiss = loader.dismiss.bind(loader);
|
||||
let isDismissed = false;
|
||||
let isPresented = false,
|
||||
isDismissed = false;
|
||||
|
||||
// Override dismiss to prevent dismissing a modal twice (it can throw an error and cause problems).
|
||||
loader.dismiss = (data, role, navOptions): Promise<any> => {
|
||||
if (isDismissed) {
|
||||
if (!isPresented || isDismissed) {
|
||||
isDismissed = true;
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1266,13 @@ export class CoreDomUtilsProvider {
|
|||
return dismiss(data, role, navOptions);
|
||||
};
|
||||
|
||||
// Wait a bit before presenting the modal, to prevent it being displayed if dissmiss is called fast.
|
||||
setTimeout(() => {
|
||||
if (!isDismissed) {
|
||||
isPresented = true;
|
||||
loader.present();
|
||||
}
|
||||
}, 40);
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue