remove deserializing config option using default config (#7491)
Signed-off-by: 21pages <pages21@163.com> Co-authored-by: squarer3 <squalerblack@gmail.com>
This commit is contained in:
parent
dd90e84f6a
commit
96e1b5b0f6
@ -317,7 +317,11 @@ pub struct PeerConfig {
|
||||
pub custom_resolutions: HashMap<String, Resolution>,
|
||||
|
||||
// The other scalar value must before this
|
||||
#[serde(default, deserialize_with = "PeerConfig::deserialize_options")]
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "deserialize_hashmap_string_string",
|
||||
skip_serializing_if = "HashMap::is_empty"
|
||||
)]
|
||||
pub options: HashMap<String, String>, // not use delete to represent default values
|
||||
// Various data for flutter ui
|
||||
#[serde(default, deserialize_with = "deserialize_hashmap_string_string")]
|
||||
@ -1230,22 +1234,8 @@ impl PeerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
fn deserialize_options<'de, D>(deserializer: D) -> Result<HashMap<String, String>, D::Error>
|
||||
where
|
||||
D: de::Deserializer<'de>,
|
||||
{
|
||||
let mut mp: HashMap<String, String> = de::Deserialize::deserialize(deserializer)?;
|
||||
Self::insert_default_options(&mut mp);
|
||||
Ok(mp)
|
||||
}
|
||||
|
||||
fn default_options() -> HashMap<String, String> {
|
||||
let mut mp: HashMap<String, String> = Default::default();
|
||||
Self::insert_default_options(&mut mp);
|
||||
return mp;
|
||||
}
|
||||
|
||||
fn insert_default_options(mp: &mut HashMap<String, String>) {
|
||||
[
|
||||
"codec-preference",
|
||||
"custom-fps",
|
||||
@ -1255,10 +1245,9 @@ impl PeerConfig {
|
||||
"swap-left-right-mouse",
|
||||
]
|
||||
.map(|key| {
|
||||
if !mp.contains_key(key) {
|
||||
mp.insert(key.to_owned(), UserDefaultConfig::read(key));
|
||||
}
|
||||
mp.insert(key.to_owned(), UserDefaultConfig::read(key));
|
||||
});
|
||||
mp
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1481,12 +1481,7 @@ impl LoginConfigHandler {
|
||||
.map(|o| !o.is_empty())
|
||||
.unwrap_or(false);
|
||||
if is_set {
|
||||
if name == "zoom-cursor" {
|
||||
self.config.options.insert(name, "".to_owned());
|
||||
} else {
|
||||
// Notice: When PeerConfig loads, the default value is taken when the option key does not exist.
|
||||
self.config.options.remove(&name);
|
||||
}
|
||||
self.config.options.remove(&name);
|
||||
} else {
|
||||
self.config.options.insert(name, "Y".to_owned());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user