Add default value ignore

This commit is contained in:
Bryce Hackel
2024-08-21 22:46:32 -07:00
parent 0d72c03167
commit beeb9eb19f
2 changed files with 20 additions and 2 deletions

View File

@@ -132,13 +132,18 @@ static const NSInteger YTLiteSection = 789;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSMutableString *settingsString = [NSMutableString string];
for (NSString *key in NSUserDefaultsCopyKeys) {
if ([userDefaults objectForKey:key]) {
NSString *value = [userDefaults objectForKey:key];
id value = [userDefaults objectForKey:key];
id defaultValue = NSUserDefaultsCopyKeysDefaults[key];
// Only include the setting if it is different from the default value
// If no default value is found, include it by default
if (value && (!defaultValue || ![value isEqual:defaultValue])) {
[settingsString appendFormat:@"%@: %@\n", key, value];
}
}
[[UIPasteboard generalPasteboard] setString:settingsString];
// Show a confirmation message or perform some other action here
[[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Settings copied"]];
}
return YES;
}
@@ -176,6 +181,7 @@ static const NSInteger YTLiteSection = 789;
}
[settingsViewController reloadData];
// Show a confirmation message or perform some other action here
[[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Settings applied"]];
}
}]];
[settingsViewController presentViewController:confirmPasteAlert animated:YES completion:nil];

View File

@@ -40,3 +40,15 @@ NSArray *NSUserDefaultsCopyKeys = @[
// Useful YouTube Keys
@"inline_muted_playback_enabled",
];
// Some default values to ignore when exporting settings
NSDictionary *NSUserDefaultsCopyKeysDefaults = @{
@"fixCasting_enabled": @1,
@"inline_muted_playback_enabled": @5,
@"newSettingsUI_enabled": @1,
@"DEMC_safeAreaConstant": @21.5,
@"RYD-ENABLED": @1,
@"RYD-VOTE-SUBMISSION": @1,
// Duplicate keys are not allowed in NSDictionary. If present, only the last one will be kept.
};