Skip to content

Commit

Permalink
Merge 86c8644 into 3dc5a72
Browse files Browse the repository at this point in the history
  • Loading branch information
acdha committed May 21, 2019
2 parents 3dc5a72 + 86c8644 commit 6ceb928
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions concordia/static/js/action-app/index.js
Expand Up @@ -43,6 +43,8 @@ export class ActionApp {
this.projects = new Map();
this.campaigns = new Map();

this.touchedAssetIDs = new Set();

this.setupGlobalKeyboardEvents();

this.setupSidebar();
Expand Down Expand Up @@ -681,18 +683,10 @@ export class ActionApp {
return {canEdit, reason};
}

updateAssetList(alwaysIncludedAssets) {
if (!alwaysIncludedAssets) {
alwaysIncludedAssets = [];
}

if (this.openAssetId) {
alwaysIncludedAssets.push(this.openAssetId);
}

updateAssetList() {
window.requestIdleCallback(() => {
console.time('Filtering assets');
let visibleAssets = this.getVisibleAssets(alwaysIncludedAssets);
let visibleAssets = this.getVisibleAssets();
console.timeEnd('Filtering assets');

console.time('Sorting assets');
Expand Down Expand Up @@ -761,16 +755,19 @@ export class ActionApp {
return sortBy(assetList, keyFromAsset);
}

getVisibleAssets(alwaysIncludedAssetIDs) {
getVisibleAssets() {
// We allow passing a list of asset IDs which should always be included
// to avoid jarring UI transitions (the display code is responsible for
// badging these as unavailable):
if (!alwaysIncludedAssetIDs) {
alwaysIncludedAssetIDs = [];

let alwaysIncludedAssetIDs = new Set(this.touchedAssetIDs);

if (this.openAssetId) {
alwaysIncludedAssetIDs.add(this.openAssetId);
}

if (this.persistentState.has('asset')) {
alwaysIncludedAssetIDs.push(this.persistentState.get('asset'));
alwaysIncludedAssetIDs.add(this.persistentState.get('asset'));
}

let currentCampaignId = this.campaignSelect.value;
Expand All @@ -793,7 +790,7 @@ export class ActionApp {
let visibleAssets = [];

for (let asset of this.assets.values()) {
if (!alwaysIncludedAssetIDs.includes(asset.id)) {
if (!alwaysIncludedAssetIDs.has(asset.id)) {
if (!asset.thumbnailUrl) {
continue;
}
Expand Down Expand Up @@ -1033,6 +1030,8 @@ export class ActionApp {
this.updateAssetList();
};

this.touchedAssetIDs.add(asset.id);

switch (action) {
case 'save':
this.postAction(
Expand Down

0 comments on commit 6ceb928

Please sign in to comment.