🎉 Add effect search

This commit is contained in:
Justin Garza
2024-11-03 03:06:26 -05:00
committed by GitHub
parent 3b4435e254
commit b3d5e06a00
2 changed files with 140 additions and 21 deletions
+27
View File
@@ -178,6 +178,29 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
});
});
// search for effect feature
this._searchEntry = this._builder.get_object('search_entry');
this._searchEntry.connect('search-changed', () => {
const query = this._searchEntry.get_text().toLowerCase();
this._effectRows.forEach(er => {
if (query === '') {
er.show(); // Show all effects if query is empty
} else {
// Show or hide each effect based on query match
const showEffect = er.name.toLowerCase().includes(query);
showEffect ? er.show() : er.hide();
// TODO
// maybe add a fuzzy search later
/*
const showEffect = utils.fuzzyMatch(er.name.toLowerCase(),
query.toLowerCase()); showEffect ? er.show() : er.hide();
*/
}
});
});
// Then add a preferences group for the effect expander rows.
const group = this._builder.get_object('effects-group');
@@ -239,6 +262,10 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
row.set_title(effect.getLabel());
}
// this is the fix for the merge issue when an effect doesn't have a discription
row.name = effect.getLabel();
// Un-expand any previously expanded effect row. This way we ensure that there
// is only one expanded row at any time.
if (hasPrefs) {