From beeb9eb19fb6b185b6d369484eecda3c4cc77d5c Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:46:32 -0700 Subject: [PATCH] Add default value ignore --- Source/Settings.xm | 10 ++++++++-- Source/SettingsKeys.h | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/Settings.xm b/Source/Settings.xm index 00e49e7..eff47c3 100644 --- a/Source/Settings.xm +++ b/Source/Settings.xm @@ -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]; diff --git a/Source/SettingsKeys.h b/Source/SettingsKeys.h index 96a5bfb..384f08b 100644 --- a/Source/SettingsKeys.h +++ b/Source/SettingsKeys.h @@ -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. +}; \ No newline at end of file