FIX: correctly always return a promise from loadMore (#19676)

This commit also fixes an issue where `loading = false` was never called when the server had nothing new to return.
This commit is contained in:
Joffrey JAFFEUX
2023-01-02 15:55:45 +01:00
committed by GitHub
parent 2f61d26e3d
commit cb2f684a43

View File

@@ -71,19 +71,19 @@ class Collection {
@bind
loadMore() {
let promise = Promise.resolve();
if (this.loading) {
return;
return promise;
}
if (
this._fetchedAll ||
(this.totalRows && this.items.length >= this.totalRows)
) {
return;
return promise;
}
let promise;
this.loading = true;
if (this.loadMoreURL) {
@@ -97,8 +97,6 @@ class Collection {
}
this.meta = result.meta;
});
} else {
promise = Promise.resolve();
}
return promise.finally(() => {