mirror of
https://github.com/SoPat712/YTLitePlus.git
synced 2025-10-29 20:10:41 -04:00
Add default value ignore
This commit is contained in:
@@ -132,13 +132,18 @@ static const NSInteger YTLiteSection = 789;
|
|||||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
NSMutableString *settingsString = [NSMutableString string];
|
NSMutableString *settingsString = [NSMutableString string];
|
||||||
for (NSString *key in NSUserDefaultsCopyKeys) {
|
for (NSString *key in NSUserDefaultsCopyKeys) {
|
||||||
if ([userDefaults objectForKey:key]) {
|
id value = [userDefaults objectForKey:key];
|
||||||
NSString *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];
|
[settingsString appendFormat:@"%@: %@\n", key, value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[[UIPasteboard generalPasteboard] setString:settingsString];
|
[[UIPasteboard generalPasteboard] setString:settingsString];
|
||||||
// Show a confirmation message or perform some other action here
|
// Show a confirmation message or perform some other action here
|
||||||
|
[[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Settings copied"]];
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@@ -176,6 +181,7 @@ static const NSInteger YTLiteSection = 789;
|
|||||||
}
|
}
|
||||||
[settingsViewController reloadData];
|
[settingsViewController reloadData];
|
||||||
// Show a confirmation message or perform some other action here
|
// 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];
|
[settingsViewController presentViewController:confirmPasteAlert animated:YES completion:nil];
|
||||||
|
|||||||
@@ -40,3 +40,15 @@ NSArray *NSUserDefaultsCopyKeys = @[
|
|||||||
// Useful YouTube Keys
|
// Useful YouTube Keys
|
||||||
@"inline_muted_playback_enabled",
|
@"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.
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user