1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 18:35:09 +01:00

Attempt to show as close as possible of the original edition list on filter/unfilter refreshes

This commit is contained in:
Brett Sun 2015-12-08 13:44:10 +01:00
parent 4fa25ca446
commit a844189e86

View File

@ -85,7 +85,7 @@ class EditionListStore {
* We often just have to refresh the edition list for a certain pieceId, * We often just have to refresh the edition list for a certain pieceId,
* this method provides exactly that functionality without any side effects * this method provides exactly that functionality without any side effects
*/ */
onRefreshEditionList({pieceId, filterBy = this.editionList[pieceId].filterBy}) { onRefreshEditionList({pieceId, filterBy}) {
const pieceEditionList = this.editionList[pieceId]; const pieceEditionList = this.editionList[pieceId];
// It may happen that the user enters the site logged in already // It may happen that the user enters the site logged in already
@ -97,16 +97,21 @@ class EditionListStore {
return; return;
} }
if (typeof filterBy !== 'object') {
filterBy = pieceEditionList.filterBy;
}
const { maxSeen, orderAsc, orderBy, pageSize } = pieceEditionList;
// to clear an array, david walsh recommends to just set it's length to zero // to clear an array, david walsh recommends to just set it's length to zero
// http://davidwalsh.name/empty-array // http://davidwalsh.name/empty-array
pieceEditionList.length = 0; pieceEditionList.length = 0;
// refetch editions from the beginning with the previous settings
EditionsListActions EditionsListActions
.fetchEditionList(pieceId, 1, pieceEditionList.pageSize, .fetchEditionList(pieceId, 1, pageSize,
pieceEditionList.orderBy, orderBy,
pieceEditionList.orderAsc, orderAsc,
filterBy) filterBy, maxSeen)
.catch(console.logGlobal); .catch(console.logGlobal);
} }