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 });
|
Object.assign(params, { course: course });
|
||||||
|
|
||||||
if (navCtrl) {
|
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 {
|
} else {
|
||||||
// Open the course in the "phantom" tab.
|
// Open the course in the "phantom" tab.
|
||||||
this.loginHelper = this.loginHelper || this.injector.get(CoreLoginHelperProvider);
|
this.loginHelper = this.loginHelper || this.injector.get(CoreLoginHelperProvider);
|
||||||
|
|
|
@ -1250,11 +1250,14 @@ export class CoreDomUtilsProvider {
|
||||||
content: text
|
content: text
|
||||||
}),
|
}),
|
||||||
dismiss = loader.dismiss.bind(loader);
|
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).
|
// Override dismiss to prevent dismissing a modal twice (it can throw an error and cause problems).
|
||||||
loader.dismiss = (data, role, navOptions): Promise<any> => {
|
loader.dismiss = (data, role, navOptions): Promise<any> => {
|
||||||
if (isDismissed) {
|
if (!isPresented || isDismissed) {
|
||||||
|
isDismissed = true;
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1263,7 +1266,13 @@ export class CoreDomUtilsProvider {
|
||||||
return dismiss(data, role, navOptions);
|
return dismiss(data, role, navOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
loader.present();
|
// 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;
|
return loader;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue