1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +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,
* 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];
// It may happen that the user enters the site logged in already
@ -97,16 +97,21 @@ class EditionListStore {
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
// http://davidwalsh.name/empty-array
pieceEditionList.length = 0;
// refetch editions from the beginning with the previous settings
EditionsListActions
.fetchEditionList(pieceId, 1, pieceEditionList.pageSize,
pieceEditionList.orderBy,
pieceEditionList.orderAsc,
filterBy)
.fetchEditionList(pieceId, 1, pageSize,
orderBy,
orderAsc,
filterBy, maxSeen)
.catch(console.logGlobal);
}