fix(zenThemesImporter): fixed wrong preferences filtering

This commit is contained in:
Bryan Galdámez 2024-09-16 12:17:18 -06:00
parent 118de1ed15
commit df1c0886d6

View file

@ -145,9 +145,13 @@ var gZenThemeImporter = new (class {
const browser = this._getBrowser(); const browser = this._getBrowser();
for (const theme of Object.values(await this.getThemes())) { for (const theme of Object.values(await this.getThemes())) {
const { preferences, areOldPreferences } = (await this._getThemePreferences(theme)).filter( const { preferences, areOldPreferences } = await this._getThemePreferences(theme);
({ type }) => type !== 'checkbox'
); if (areOldPreferences) {
continue;
}
const filteredPreferences = preferences.filter(({ type }) => type !== 'checkbox');
const sanitizedName = `theme-${theme.name?.replaceAll(/\s/g, '-')?.replaceAll(/[^A-z_-]+/g, '')}`; const sanitizedName = `theme-${theme.name?.replaceAll(/\s/g, '-')?.replaceAll(/[^A-z_-]+/g, '')}`;
if (!theme.enabled) { if (!theme.enabled) {
@ -157,17 +161,17 @@ var gZenThemeImporter = new (class {
element.remove(); element.remove();
} }
if (document.querySelector(':root').style.hasProperty(`--${sanitizedProperty}`)) { for (const { property } of filteredPreferences) {
document.querySelector(':root').style.removeProperty(`--${sanitizedProperty}`); const sanitizedProperty = property?.replaceAll(/\./g, '-');
if (document.querySelector(':root').style.hasProperty(`--${sanitizedProperty}`)) {
document.querySelector(':root').style.removeProperty(`--${sanitizedProperty}`);
}
} }
continue; continue;
} }
if (areOldPreferences) {
continue;
}
for (const { property, type } of preferences) { for (const { property, type } of preferences) {
const value = Services.prefs.getStringPref(property, ''); const value = Services.prefs.getStringPref(property, '');
const sanitizedProperty = property?.replaceAll(/\./g, '-'); const sanitizedProperty = property?.replaceAll(/\./g, '-');