mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
don't depend on matching handlers with overlapping requests
This commit is contained in:
parent
421edbfa1e
commit
020d622302
2 changed files with 22 additions and 9 deletions
|
@ -525,7 +525,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
onPrimaryFilter_displayNameChanged: {
|
||||
purchasesModel.tagsFilter = filterBar.primaryFilter_filterName.toLowerCase();
|
||||
purchasesModel.tagsFilter = filterBar.primaryFilter_filterName;
|
||||
filterBar.previousPrimaryFilter = filterBar.primaryFilter_displayName;
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ Rectangle {
|
|||
console.debug('getPage', purchasesModel.listModelName, root.isShowingMyItems, filterBar.primaryFilter_filterName, purchasesModel.currentPageToRetrieve, purchasesModel.itemsPerPage);
|
||||
Commerce.inventory(
|
||||
root.isShowingMyItems ? "proofs" : "purchased",
|
||||
filterBar.primaryFilter_filterName.toLowerCase(),
|
||||
filterBar.primaryFilter_filterName,
|
||||
filterBar.text,
|
||||
purchasesModel.currentPageToRetrieve,
|
||||
purchasesModel.itemsPerPage
|
||||
|
|
|
@ -36,11 +36,9 @@ ListModel {
|
|||
Component.onCompleted: initialized = true;
|
||||
onEndpointChanged: if (initialized) { getFirstPage('delayClear'); }
|
||||
onSortKeyChanged: if (initialized) { getFirstPage('delayClear'); }
|
||||
onSearchFilterChanged: {
|
||||
if (!initialized) { return; }
|
||||
getFirstPage('delayClear');
|
||||
}
|
||||
onSearchFilterChanged: if (initialized) { getFirstPage('delayClear'); }
|
||||
onTagsFilterChanged: if (initialized) { getFirstPage('delayClear'); }
|
||||
|
||||
property int itemsPerPage: 100;
|
||||
|
||||
// State.
|
||||
|
@ -64,7 +62,7 @@ ListModel {
|
|||
// Check consistency and call processPage.
|
||||
function handlePage(error, response) {
|
||||
var processed;
|
||||
console.debug('handlePage', listModelName, error, JSON.stringify(response));
|
||||
console.debug('handlePage', listModelName, additionalFirstPageRequested, error, JSON.stringify(response));
|
||||
function fail(message) {
|
||||
console.warn("Warning page fail", listModelName, JSON.stringify(message));
|
||||
currentPageToRetrieve = -1;
|
||||
|
@ -92,7 +90,17 @@ ListModel {
|
|||
}
|
||||
root.append(processed); // FIXME keep index steady, and apply any post sort
|
||||
retrievedAtLeastOnePage = true;
|
||||
console.debug(listModelName, 'after handlePage count', root.count);
|
||||
// Suppose two properties change at once, and both of their change handlers request a new first page.
|
||||
// (An example is when the a filter box gets cleared with text in it, so that the search and tags are both reset.)
|
||||
// Or suppose someone just types new search text quicker than the server response.
|
||||
// In these cases, we would have multiple requests in flight, and signal based responses aren't generally very good
|
||||
// at matching up the right handler with the right message. Rather than require all the APIs to carefully handle such,
|
||||
// and also to cut down on useless requests, we take care of that case here.
|
||||
if (additionalFirstPageRequested) {
|
||||
console.debug('deferred getFirstPage', listModelName);
|
||||
additionalFirstPageRequested = false;
|
||||
getFirstPage('delayedClear');
|
||||
}
|
||||
}
|
||||
function debugView(label) {
|
||||
if (!listView) { return; }
|
||||
|
@ -128,13 +136,18 @@ ListModel {
|
|||
// Start the show by retrieving data according to `getPage()`.
|
||||
// It can be custom-defined by this item's Parent.
|
||||
property var getFirstPage: function (delayClear) {
|
||||
if (requestPending) {
|
||||
console.debug('deferring getFirstPage', listModelName);
|
||||
additionalFirstPageRequested = true;
|
||||
return;
|
||||
}
|
||||
delayedClear = !!delayClear;
|
||||
resetModel();
|
||||
requestPending = true;
|
||||
console.debug("getFirstPage", listModelName, currentPageToRetrieve);
|
||||
getPage();
|
||||
}
|
||||
|
||||
property bool additionalFirstPageRequested: false;
|
||||
property bool requestPending: false; // For de-bouncing getNextPage.
|
||||
// This function, will get the _next_ page of data according to `getPage()`.
|
||||
// It can be custom-defined by this item's Parent. Typical usage:
|
||||
|
|
Loading…
Reference in a new issue