diff --git a/src/gui/html/js/filters.js b/src/gui/html/js/filters.js
index f3f2b391..d070e679 100644
--- a/src/gui/html/js/filters.js
+++ b/src/gui/html/js/filters.js
@@ -97,7 +97,33 @@
}).catch(handlePromiseError);
}
+ areAnyFiltersActive() {
+ return this.hideMessagelessPlugins
+ || this.hideInactivePlugins
+ || this.conflictingPluginNames
+ || this.contentSearchString
+ || this.hideVersionNumbers
+ || this.hideCRCs
+ || this.hideBashTags
+ || this.hideAllPluginMessages
+ || this.hideNotes
+ || this.hideDoNotCleanMessages;
+ }
+
+ load(filterSettings) {
+ if (filterSettings) {
+ Object.getOwnPropertyNames(filterSettings).forEach((filter) => {
+ this[filter] = filterSettings[filter];
+ document.getElementById(filter).checked = this[filter];
+ });
+ }
+ }
+
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 df97f1db..ab6e53de 100644
--- a/src/gui/html/js/initialise.js
+++ b/src/gui/html/js/initialise.js
@@ -117,39 +117,6 @@
document.addEventListener('loot-game-plugins-change', Game.onPluginsChange);
}
- function applyEnabledFilters(filters, settings, plugins) {
- if (!filters) {
- return;
- }
-
- if (settings.filters) {
- Object.getOwnPropertyNames(settings.filters).forEach((filter) => {
- filters[filter] = settings.filters[filter];
- document.getElementById(filter).checked = filters[filter];
- });
- }
-
- if (filters.hideMessagelessPlugins
- || filters.hideInactivePlugins
- || filters.hideNotes
- || filters.hideDoNotCleanMessages
- || filters.hideAllPluginMessages) {
- filters.apply(plugins);
- }
-
- if (filters.hideVersionNumbers) {
- document.getElementById('hideVersionNumbers').dispatchEvent(new Event('change'));
- }
-
- if (filters.hideCRCs) {
- document.getElementById('hideCRCs').dispatchEvent(new Event('change'));
- }
-
- if (filters.hideBashTags) {
- document.getElementById('hideBashTags').dispatchEvent(new Event('change'));
- }
- }
-
function splitVersion(version) {
const lastPeriodIndex = version.lastIndexOf('.');
return {
@@ -211,7 +178,8 @@
document.getElementById('cardsNav').items = appData.game.plugins;
document.getElementById('pluginCardList').items = appData.game.plugins;
appData.Filters.fillConflictsFilterList(appData.game.plugins);
- applyEnabledFilters(appData.filters, appData.settings, appData.game.plugins);
+ appData.filters.load(appData.settings.filters);
+ appData.filters.apply(appData.game.plugins);
Dialog.closeProgress();
});
}