settings: Use a derive macro for refine (#38451)
When we refactored settings to not pass JSON blobs around, we ended up needing to write *a lot* of code that just merged things (like json merge used to do). Use a derive macro to prevent typos in this logic. Release Notes: - N/A
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use gpui::App;
|
||||
use settings::Settings;
|
||||
use util::MergeFrom;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CallSettings {
|
||||
@@ -9,7 +8,7 @@ pub struct CallSettings {
|
||||
}
|
||||
|
||||
impl Settings for CallSettings {
|
||||
fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
|
||||
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
|
||||
let call = content.calls.clone().unwrap();
|
||||
CallSettings {
|
||||
mute_on_join: call.mute_on_join.unwrap(),
|
||||
@@ -17,13 +16,6 @@ impl Settings for CallSettings {
|
||||
}
|
||||
}
|
||||
|
||||
fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
|
||||
if let Some(call) = content.calls.clone() {
|
||||
self.mute_on_join.merge_from(&call.mute_on_join);
|
||||
self.share_on_join.merge_from(&call.share_on_join);
|
||||
}
|
||||
}
|
||||
|
||||
fn import_from_vscode(
|
||||
_vscode: &settings::VsCodeSettings,
|
||||
_current: &mut settings::SettingsContent,
|
||||
|
||||
Reference in New Issue
Block a user