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,
|
||||
componentProps: { items },
|
||||
id: 'actionsmenu-popover',
|
||||
|
|
|
@ -197,7 +197,7 @@ export class AddonModQuizAutoSave {
|
|||
};
|
||||
this.popoverShown = true;
|
||||
|
||||
this.popover = await CoreDomUtils.openPopover({
|
||||
this.popover = await CoreDomUtils.openPopoverWithoutResult({
|
||||
component: AddonModQuizConnectionErrorComponent,
|
||||
event: <Event> event,
|
||||
});
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
</div>
|
||||
</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>
|
||||
|
||||
|
|
|
@ -109,13 +109,11 @@ export class CoreInfiniteLoadingComponent implements OnChanges {
|
|||
/**
|
||||
* Complete loading.
|
||||
*/
|
||||
complete(): void {
|
||||
if (this.position == 'top') {
|
||||
// Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't.
|
||||
setTimeout(() => this.completeLoadMore(), 400);
|
||||
} else {
|
||||
this.completeLoadMore();
|
||||
}
|
||||
async complete(): Promise<void> {
|
||||
// Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't.
|
||||
await CoreUtils.wait(400);
|
||||
|
||||
await this.completeLoadMore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -131,7 +131,7 @@ export class CoreCourseModuleCompletionComponent
|
|||
target = target.parentElement;
|
||||
}
|
||||
|
||||
CoreDomUtils.openPopover({
|
||||
CoreDomUtils.openPopoverWithoutResult({
|
||||
component: CoreCourseModuleCompletionDetailsComponent,
|
||||
componentProps: {
|
||||
completion: this.completion,
|
||||
|
|
|
@ -548,7 +548,7 @@ export class CoreDomUtilsProvider {
|
|||
el.addEventListener('click', async (ev: Event) => {
|
||||
const html = el.getAttribute('data-html');
|
||||
|
||||
await CoreDomUtils.openPopover({
|
||||
await CoreDomUtils.openPopoverWithoutResult({
|
||||
component: CoreBSTooltipComponent,
|
||||
componentProps: {
|
||||
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.
|
||||
* @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> {
|
||||
|
||||
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);
|
||||
|
||||
await popover.present();
|
||||
|
@ -1559,10 +1574,7 @@ export class CoreDomUtilsProvider {
|
|||
}
|
||||
}
|
||||
|
||||
const result = waitForDismissCompleted ? await popover.onDidDismiss<T>() : await popover.onWillDismiss<T>();
|
||||
if (result?.data) {
|
||||
return result?.data;
|
||||
}
|
||||
return popover;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue