Added check to stop the infinite list procedure if there is no more data to fetch

This commit is contained in:
Sergi Carol 2017-03-15 09:27:49 +01:00
parent 5400d16259
commit 1e08f94242
1 changed files with 10 additions and 4 deletions

View File

@ -28,9 +28,9 @@ export class InfiniteList {
method: string; method: string;
/** /**
* Domain of the method * Domain of the method
* @type {string} * @type {array}
*/ */
domain: string; domain: any[];
/** /**
* Fields to search * Fields to search
* @type {Array<string>} * @type {Array<string>}
@ -72,10 +72,16 @@ export class InfiniteList {
* @param {any} infiniteScroll Infinite scroll event * @param {any} infiniteScroll Infinite scroll event
*/ */
doInfinite(infiniteScroll: any) { doInfinite(infiniteScroll: any) {
if (this.list_items.length == 0)
infiniteScroll.enable(false);
console.log("Begin async op"); console.log("Begin async op");
this.loadData().then(() => { this.loadData().then(() => {
infiniteScroll.complete() // Disable scroll if list is empty
if (this.list_items.length == 0)
//infiniteScroll.enable(false);
console.log(this.list_items)
infiniteScroll.complete();
}) })
} }