Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Settings): Preferences with the same key in different c…
Browse files Browse the repository at this point in the history
…ategories did not appear in search results

Some preferences with identical keys were not functioning correctly when they belonged to different categories. This fix ensures that each preference is handled uniquely by considering its category and key together.

Preferences with the same key within the same category, such as 'revanced_spoof_app_version_target,' still only show the first matched key.
  • Loading branch information
anddea committed Sep 9, 2024
1 parent 08c3622 commit e23c3e3
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ private void addPreferenceAndDependencies(Preference preference, Set<String> key
*/
private void addPreferenceWithDependencies(PreferenceGroup preferenceGroup, Preference preference) {
String key = preference.getKey();
if (key != null && !addedPreferences.contains(key)) {

// Instead of just using preference keys, we combine the category and key to ensure uniqueness
if (key != null && !addedPreferences.contains(preferenceGroup.getTitle() + ":" + key)) {
// Add dependencies first
if (preference.getDependency() != null) {
String dependencyKey = preference.getDependency();
Expand All @@ -557,16 +559,16 @@ private void addPreferenceWithDependencies(PreferenceGroup preferenceGroup, Pref
addPreferenceWithDependencies(preferenceGroup, dependency);
} else {
Logger.printDebug(() -> "SearchFragment: Dependency not found for key: " + dependencyKey);
// Skip adding this preference as its dependency is not found
return;
}
}

// Add the preference using a combination of the category and the key
preferenceGroup.addPreference(preference);
addedPreferences.add(key);
addedPreferences.add(preferenceGroup.getTitle() + ":" + key); // Track based on both category and key
Logger.printDebug(() -> "SearchFragment: Added preference with key: " + key);

// Add dependent preferences
// Handle dependent preferences
if (dependencyMap.containsKey(key)) {
Logger.printDebug(() -> "SearchFragment: Adding dependent preferences for key: " + key);
for (Preference dependentPreference : Objects.requireNonNull(dependencyMap.get(key))) {
Expand Down

0 comments on commit e23c3e3

Please sign in to comment.