Don't reset the page selection if the results have changed while the user
was browsing exiting results This is most noticeable when viewing results in xephyr, and then opening a document in your regular session. But it could also be noticeable if downloading a new file completes while the user is in the overlay. This patch also moves the call to _displayMatchedItems() to _redisplay instead of making it in both _setDefaultList() and _doSearchFilter().
This commit is contained in:
parent
39eb563687
commit
30a9c6b2f4
@ -131,7 +131,7 @@ AppDisplay.prototype = {
|
||||
// We still need to determine what events other than search can trigger
|
||||
// a change in the set of applications that are being shown while the
|
||||
// user in in the overlay mode, however let's redisplay just in case.
|
||||
me._redisplay();
|
||||
me._redisplay(false);
|
||||
});
|
||||
|
||||
// Load the GAppInfos now so it doesn't slow down the first
|
||||
@ -174,7 +174,6 @@ AppDisplay.prototype = {
|
||||
this._matchedItems.push(appId);
|
||||
}
|
||||
}
|
||||
this._displayMatchedItems(true);
|
||||
},
|
||||
|
||||
// Compares items associated with the item ids based on the alphabetical order
|
||||
|
@ -110,7 +110,7 @@ DocDisplay.prototype = {
|
||||
// but redisplaying right away is cool when we use Zephyr.
|
||||
// Also, we might be displaying remote documents, like Google Docs, in the future
|
||||
// which might be edited by someone else.
|
||||
me._redisplay();
|
||||
me._redisplay(false);
|
||||
});
|
||||
},
|
||||
|
||||
@ -163,8 +163,6 @@ DocDisplay.prototype = {
|
||||
}
|
||||
|
||||
this._matchedItems.sort(Lang.bind(this, function (a,b) { return this._compareItems(a,b); }));
|
||||
|
||||
this._displayMatchedItems(true);
|
||||
},
|
||||
|
||||
// Compares items associated with the item ids based on how recently the items
|
||||
|
@ -225,7 +225,7 @@ GenericDisplay.prototype = {
|
||||
// Sets the search string and displays the matching items.
|
||||
setSearch: function(text) {
|
||||
this._search = text.toLowerCase();
|
||||
this._redisplay();
|
||||
this._redisplay(true);
|
||||
},
|
||||
|
||||
// Sets this._activatedItem to the item that is selected and emits 'activated' signal.
|
||||
@ -314,13 +314,14 @@ GenericDisplay.prototype = {
|
||||
this._setDimensionsAndMaxItems(width, height);
|
||||
this._grid.width = this._width;
|
||||
this._grid.height = this._height;
|
||||
this._pageDisplayed = 0;
|
||||
this._displayMatchedItems(true);
|
||||
},
|
||||
|
||||
// Updates the displayed items and makes the display actor visible.
|
||||
show: function() {
|
||||
this._keepDisplayCurrent = true;
|
||||
this._redisplay();
|
||||
this._redisplay(true);
|
||||
this._grid.show();
|
||||
},
|
||||
|
||||
@ -337,19 +338,17 @@ GenericDisplay.prototype = {
|
||||
* Displays items that match the current request and should show up on the current page.
|
||||
* Updates the display control to reflect the matched items set and the page selected.
|
||||
*
|
||||
* matchedItemsChanged - indicates if the set of the matched items changed prior to the
|
||||
* request. If it did, the current page is reset to 0 and the display
|
||||
* control is updated.
|
||||
* resetDisplayControl - indicates if the display control should be re-created because
|
||||
* the results or the space allocated for them changed. If it's false,
|
||||
* the existing display control is used and only the page links are
|
||||
* updated to reflect the current page selection.
|
||||
*/
|
||||
_displayMatchedItems: function(matchedItemsChanged) {
|
||||
_displayMatchedItems: function(resetDisplayControl) {
|
||||
// When generating a new list to display, we first remove all the old
|
||||
// displayed items which will unset the selection. So we need
|
||||
// to keep a flag which indicates if this display had the selection.
|
||||
let hadSelected = this.hasSelected();
|
||||
|
||||
if (matchedItemsChanged)
|
||||
this._pageDisplayed = 0;
|
||||
|
||||
this._removeAllDisplayItems();
|
||||
|
||||
for (let i = this._maxItemsPerPage * this._pageDisplayed; i < this._matchedItems.length && i < this._maxItemsPerPage * (this._pageDisplayed + 1); i++) {
|
||||
@ -362,7 +361,7 @@ GenericDisplay.prototype = {
|
||||
this.selectFirstItem();
|
||||
}
|
||||
|
||||
this._updateDisplayControl(matchedItemsChanged);
|
||||
this._updateDisplayControl(resetDisplayControl);
|
||||
},
|
||||
|
||||
// Creates a display item based on the information associated with itemId
|
||||
@ -434,8 +433,16 @@ GenericDisplay.prototype = {
|
||||
this._removeDisplayItem(itemId);
|
||||
},
|
||||
|
||||
// Updates the displayed items, applying the search string if one exists.
|
||||
_redisplay: function() {
|
||||
/*
|
||||
* Updates the displayed items, applying the search string if one exists.
|
||||
*
|
||||
* resetPage - indicates if the page selection should be reset when displaying the matching results.
|
||||
* We reset the page selection when the change in results was initiated by the user by
|
||||
* entering a different search criteria or by viewing the results list in a different
|
||||
* size mode, but we keep the page selection the same if the results got updated on
|
||||
* their own while the user was browsing through the result pages.
|
||||
*/
|
||||
_redisplay: function(resetPage) {
|
||||
if (!this._keepDisplayCurrent)
|
||||
return;
|
||||
|
||||
@ -445,6 +452,11 @@ GenericDisplay.prototype = {
|
||||
else
|
||||
this._doSearchFilter();
|
||||
|
||||
if (resetPage)
|
||||
this._pageDisplayed = 0;
|
||||
|
||||
this._displayMatchedItems(true);
|
||||
|
||||
this.emit('redisplayed');
|
||||
},
|
||||
|
||||
@ -492,8 +504,7 @@ GenericDisplay.prototype = {
|
||||
this._height = maxItemsInColumn * ITEM_DISPLAY_HEIGHT;
|
||||
},
|
||||
|
||||
// Applies the search string to the list of items to find matches,
|
||||
// and displays the matching items.
|
||||
// Applies the search string to the list of items to find matches, and displays the matching items.
|
||||
_doSearchFilter: function() {
|
||||
let matchedItemsForSearch = {};
|
||||
|
||||
@ -529,8 +540,6 @@ GenericDisplay.prototype = {
|
||||
else
|
||||
return this._compareItems(a, b);
|
||||
}));
|
||||
|
||||
this._displayMatchedItems(true);
|
||||
},
|
||||
|
||||
// Displays the page specified by the pageNumber argument. The pageNumber is 0-based.
|
||||
@ -542,13 +551,13 @@ GenericDisplay.prototype = {
|
||||
/*
|
||||
* Updates the display control to reflect the matched items set and the page selected.
|
||||
*
|
||||
* matchedItemsChanged - indicates if the set of the matched items changed prior to the
|
||||
* request. If it did, the display control is updated to reflect the
|
||||
* new set of pages. Otherwise, the page links are updated for the
|
||||
* current set of pages.
|
||||
* resetDisplayControl - indicates if the display control should be re-created because
|
||||
* the results or the space allocated for them changed. If it's false,
|
||||
* the existing display control is used and only the page links are
|
||||
* updated to reflect the current page selection.
|
||||
*/
|
||||
_updateDisplayControl: function(matchedItemsChanged) {
|
||||
if (matchedItemsChanged) {
|
||||
_updateDisplayControl: function(resetDisplayControl) {
|
||||
if (resetDisplayControl) {
|
||||
this.displayControl.remove_all();
|
||||
let pageNumber = 0;
|
||||
for (let i = 0; i < this._matchedItems.length; i = i + this._maxItemsPerPage) {
|
||||
|
Loading…
Reference in New Issue
Block a user