mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-06 01:55:50 +01:00
fix(YouTube - Settings): Do not show a toast if migrating old unknown settings
This commit is contained in:
parent
eba73c5947
commit
f2e15a2e1f
@ -224,6 +224,7 @@ public abstract class Setting<T> {
|
|||||||
if (!oldPrefs.preferences.contains(settingKey)) {
|
if (!oldPrefs.preferences.contains(settingKey)) {
|
||||||
return; // Nothing to do.
|
return; // Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
Object newValue = setting.get();
|
Object newValue = setting.get();
|
||||||
final Object migratedValue;
|
final Object migratedValue;
|
||||||
if (setting instanceof BooleanSetting) {
|
if (setting instanceof BooleanSetting) {
|
||||||
@ -238,13 +239,17 @@ public abstract class Setting<T> {
|
|||||||
migratedValue = oldPrefs.getString(settingKey, (String) newValue);
|
migratedValue = oldPrefs.getString(settingKey, (String) newValue);
|
||||||
} else {
|
} else {
|
||||||
Logger.printException(() -> "Unknown setting: " + setting);
|
Logger.printException(() -> "Unknown setting: " + setting);
|
||||||
|
// Remove otherwise it'll show a toast on every launch
|
||||||
|
oldPrefs.preferences.edit().remove(settingKey).apply();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldPrefs.preferences.edit().remove(settingKey).apply(); // Remove the old setting.
|
oldPrefs.preferences.edit().remove(settingKey).apply(); // Remove the old setting.
|
||||||
if (migratedValue.equals(newValue)) {
|
if (migratedValue.equals(newValue)) {
|
||||||
Logger.printDebug(() -> "Value does not need migrating: " + settingKey);
|
Logger.printDebug(() -> "Value does not need migrating: " + settingKey);
|
||||||
return; // Old value is already equal to the new setting value.
|
return; // Old value is already equal to the new setting value.
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.printDebug(() -> "Migrating old preference value into current preference: " + settingKey);
|
Logger.printDebug(() -> "Migrating old preference value into current preference: " + settingKey);
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
setting.save(migratedValue);
|
setting.save(migratedValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user