mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-27 16:22:11 +08:00
fix: remove unnecessary allow_auto_update default value (#7697)
* fix: remove unnecessary allow_auto_update default value * fix: normalize missing profile auto-update state --------- Co-authored-by: wonfen <eiwonfen@gmail.com>
This commit is contained in:
@@ -109,7 +109,6 @@ pub struct PrfOption {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub danger_accept_invalid_certs: Option<bool>,
|
||||
|
||||
#[serde(default = "default_allow_auto_update")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub allow_auto_update: Option<bool>,
|
||||
|
||||
@@ -579,12 +578,6 @@ impl PrfItem {
|
||||
}
|
||||
}
|
||||
|
||||
// 向前兼容,默认为订阅启用自动更新
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
const fn default_allow_auto_update() -> Option<bool> {
|
||||
Some(true)
|
||||
}
|
||||
|
||||
fn allow_auto_update_enabled(option: Option<&PrfOption>) -> bool {
|
||||
option.and_then(|o| o.allow_auto_update).unwrap_or(true)
|
||||
}
|
||||
|
||||
@@ -138,6 +138,12 @@ impl IProfiles {
|
||||
if item.uid.is_none() {
|
||||
item.uid = Some(help::get_uid("d").into());
|
||||
}
|
||||
if item.itype.as_deref() == Some("remote") {
|
||||
item.option
|
||||
.get_or_insert_with(PrfOption::default)
|
||||
.allow_auto_update
|
||||
.get_or_insert(true);
|
||||
}
|
||||
}
|
||||
profiles
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
|
||||
option: {
|
||||
with_proxy: false,
|
||||
self_proxy: false,
|
||||
allow_auto_update: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -418,7 +419,11 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
|
||||
<InputLabel>
|
||||
{t('profiles.modals.profileForm.fields.allowAutoUpdate')}
|
||||
</InputLabel>
|
||||
<Switch checked={field.value} {...field} color="primary" />
|
||||
<Switch
|
||||
checked={field.value ?? true}
|
||||
{...field}
|
||||
color="primary"
|
||||
/>
|
||||
</StyledBox>
|
||||
)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user