Merge pull request #4040 from dpalou/MOBILE-4470
MOBILE-4470 infinite-loading: Fix consecutive loads not workingmain
commit
6cd3984905
|
@ -200,7 +200,7 @@ export class AddonModDataActionComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await CoreDomUtils.openPopover({
|
await CoreDomUtils.openPopoverWithoutResult({
|
||||||
component: AddonModDataActionsMenuComponent,
|
component: AddonModDataActionsMenuComponent,
|
||||||
componentProps: { items },
|
componentProps: { items },
|
||||||
id: 'actionsmenu-popover',
|
id: 'actionsmenu-popover',
|
||||||
|
|
|
@ -197,7 +197,7 @@ export class AddonModQuizAutoSave {
|
||||||
};
|
};
|
||||||
this.popoverShown = true;
|
this.popoverShown = true;
|
||||||
|
|
||||||
this.popover = await CoreDomUtils.openPopover({
|
this.popover = await CoreDomUtils.openPopoverWithoutResult({
|
||||||
component: AddonModQuizConnectionErrorComponent,
|
component: AddonModQuizConnectionErrorComponent,
|
||||||
event: <Event> event,
|
event: <Event> event,
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ion-infinite-scroll [disabled]="!enabled || error || loadingMore" (ionInfinite)="loadMore()" [position]="position">
|
<!-- Don't allow disabling infinite-scroll while loading more items, otherwise infinite scroll stops working. -->
|
||||||
|
<ion-infinite-scroll [disabled]="!loadingMore && (!enabled || error)" (ionInfinite)="loadMore()" [position]="position">
|
||||||
<ion-infinite-scroll-content />
|
<ion-infinite-scroll-content />
|
||||||
</ion-infinite-scroll>
|
</ion-infinite-scroll>
|
||||||
|
|
||||||
|
|
|
@ -109,13 +109,11 @@ export class CoreInfiniteLoadingComponent implements OnChanges {
|
||||||
/**
|
/**
|
||||||
* Complete loading.
|
* Complete loading.
|
||||||
*/
|
*/
|
||||||
complete(): void {
|
async complete(): Promise<void> {
|
||||||
if (this.position == 'top') {
|
// Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't.
|
||||||
// Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't.
|
await CoreUtils.wait(400);
|
||||||
setTimeout(() => this.completeLoadMore(), 400);
|
|
||||||
} else {
|
await this.completeLoadMore();
|
||||||
this.completeLoadMore();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -131,7 +131,7 @@ export class CoreCourseModuleCompletionComponent
|
||||||
target = target.parentElement;
|
target = target.parentElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreDomUtils.openPopover({
|
CoreDomUtils.openPopoverWithoutResult({
|
||||||
component: CoreCourseModuleCompletionDetailsComponent,
|
component: CoreCourseModuleCompletionDetailsComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
completion: this.completion,
|
completion: this.completion,
|
||||||
|
|
|
@ -548,7 +548,7 @@ export class CoreDomUtilsProvider {
|
||||||
el.addEventListener('click', async (ev: Event) => {
|
el.addEventListener('click', async (ev: Event) => {
|
||||||
const html = el.getAttribute('data-html');
|
const html = el.getAttribute('data-html');
|
||||||
|
|
||||||
await CoreDomUtils.openPopover({
|
await CoreDomUtils.openPopoverWithoutResult({
|
||||||
component: CoreBSTooltipComponent,
|
component: CoreBSTooltipComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
content,
|
content,
|
||||||
|
@ -1534,7 +1534,7 @@ export class CoreDomUtilsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a popover.
|
* Opens a popover and waits for it to be dismissed to return the result.
|
||||||
*
|
*
|
||||||
* @param options Options.
|
* @param options Options.
|
||||||
* @returns Promise resolved when the popover is dismissed or will be dismissed.
|
* @returns Promise resolved when the popover is dismissed or will be dismissed.
|
||||||
|
@ -1542,7 +1542,22 @@ export class CoreDomUtilsProvider {
|
||||||
async openPopover<T = void>(options: OpenPopoverOptions): Promise<T | undefined> {
|
async openPopover<T = void>(options: OpenPopoverOptions): Promise<T | undefined> {
|
||||||
|
|
||||||
const { waitForDismissCompleted, ...popoverOptions } = options;
|
const { waitForDismissCompleted, ...popoverOptions } = options;
|
||||||
const popover = await PopoverController.create(popoverOptions);
|
const popover = await this.openPopoverWithoutResult(popoverOptions);
|
||||||
|
|
||||||
|
const result = waitForDismissCompleted ? await popover.onDidDismiss<T>() : await popover.onWillDismiss<T>();
|
||||||
|
if (result?.data) {
|
||||||
|
return result?.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a popover.
|
||||||
|
*
|
||||||
|
* @param options Options.
|
||||||
|
* @returns Promise resolved when the popover is displayed.
|
||||||
|
*/
|
||||||
|
async openPopoverWithoutResult(options: Omit<PopoverOptions, 'showBackdrop'>): Promise<HTMLIonPopoverElement> {
|
||||||
|
const popover = await PopoverController.create(options);
|
||||||
const zoomLevel = await CoreConfig.get(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreConstants.CONFIG.defaultZoomLevel);
|
const zoomLevel = await CoreConfig.get(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreConstants.CONFIG.defaultZoomLevel);
|
||||||
|
|
||||||
await popover.present();
|
await popover.present();
|
||||||
|
@ -1559,10 +1574,7 @@ export class CoreDomUtilsProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = waitForDismissCompleted ? await popover.onDidDismiss<T>() : await popover.onWillDismiss<T>();
|
return popover;
|
||||||
if (result?.data) {
|
|
||||||
return result?.data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue