diff --git a/src/gui/html/js/events.js b/src/gui/html/js/events.js
index 5b5ae282..e9c29467 100644
--- a/src/gui/html/js/events.js
+++ b/src/gui/html/js/events.js
@@ -63,7 +63,11 @@ function onChangeGame(evt) {
loot.Filters.fillConflictsFilterList(loot.game.plugins);
/* Now update virtual lists. */
- loot.filters.apply(loot.game.plugins);
+ if (loot.filters.areAnyFiltersActive()) {
+ loot.filters.apply(loot.game.plugins);
+ } else {
+ loot.DOM.initialiseVirtualLists(loot.game.plugins);
+ }
loot.Dialog.closeProgress();
}).catch(loot.handlePromiseError);
@@ -237,7 +241,11 @@ function onContentRefresh() {
loot.Filters.fillConflictsFilterList(loot.game.plugins);
/* Reapply filters. */
- loot.filters.apply(loot.game.plugins);
+ if (loot.filters.areAnyFiltersActive()) {
+ loot.filters.apply(loot.game.plugins);
+ } else {
+ loot.DOM.initialiseVirtualLists(loot.game.plugins);
+ }
loot.Dialog.closeProgress();
}).catch(loot.handlePromiseError);
diff --git a/src/gui/html/js/filters.js b/src/gui/html/js/filters.js
index d070e679..4a495575 100644
--- a/src/gui/html/js/filters.js
+++ b/src/gui/html/js/filters.js
@@ -100,8 +100,8 @@
areAnyFiltersActive() {
return this.hideMessagelessPlugins
|| this.hideInactivePlugins
- || this.conflictingPluginNames
- || this.contentSearchString
+ || this.conflictingPluginNames.length !== 0
+ || this.contentSearchString.length !== 0
|| this.hideVersionNumbers
|| this.hideCRCs
|| this.hideBashTags
@@ -120,10 +120,6 @@
}
apply(plugins) {
- if (!this.areAnyFiltersActive()) {
- return;
- }
-
const filteredPlugins = plugins.filter(this.pluginFilter, this);
document.getElementById('cardsNav').items = filteredPlugins;
diff --git a/src/gui/html/js/initialise.js b/src/gui/html/js/initialise.js
index 81c3b875..0d2d397c 100644
--- a/src/gui/html/js/initialise.js
+++ b/src/gui/html/js/initialise.js
@@ -176,10 +176,14 @@
const game = JSON.parse(result, Plugin.fromJson);
appData.game = new Game(game, appData.l10n);
- dom.initialiseVirtualLists(appData.game.plugins);
appData.Filters.fillConflictsFilterList(appData.game.plugins);
appData.filters.load(appData.settings.filters);
- appData.filters.apply(appData.game.plugins);
+
+ if (appData.filters.areAnyFiltersActive()) {
+ appData.filters.apply(appData.game.plugins);
+ } else {
+ dom.initialiseVirtualLists(appData.game.plugins);
+ }
Dialog.closeProgress();
});
diff --git a/src/tests/gui/html/js/test_filters.js b/src/tests/gui/html/js/test_filters.js
index e33ce78a..82bcd155 100644
--- a/src/tests/gui/html/js/test_filters.js
+++ b/src/tests/gui/html/js/test_filters.js
@@ -255,4 +255,76 @@ describe('Filters', () => {
filters.activateConflictsFilter().should.finally.deepEqual([]);
});
});
+
+ describe('#areAnyFiltersActive', () => {
+ let filters;
+
+ beforeEach(() => {
+ filters = new loot.Filters(l10n);
+ });
+
+ it('should return false if all the boolean filters are false, and the content and conflict filter lengths are zero', () => {
+ filters.areAnyFiltersActive().should.be.false();
+ });
+
+ it('should return true if hideMessagelessPlugins is true', () => {
+ filters.hideMessagelessPlugins = true;
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if hideInactivePlugins is true', () => {
+ filters.hideInactivePlugins = true;
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if hideVersionNumbers is true', () => {
+ filters.hideVersionNumbers = true;
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if hideCRCs is true', () => {
+ filters.hideCRCs = true;
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if hideBashTags is true', () => {
+ filters.hideBashTags = true;
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if hideAllPluginMessages is true', () => {
+ filters.hideAllPluginMessages = true;
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if hideNotes is true', () => {
+ filters.hideNotes = true;
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if hideDoNotCleanMessages is true', () => {
+ filters.hideDoNotCleanMessages = true;
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if conflictingPluginNames is a non-empty array', () => {
+ filters.conflictingPluginNames = ['foo'];
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+
+ it('should return true if contentSearchString is a non-empty string', () => {
+ filters.contentSearchString = 'foo';
+
+ filters.areAnyFiltersActive().should.be.true();
+ });
+ });
});