mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-09 03:42:06 +08:00
refactor: api cleanup (#7812)
* refactor(config): unify YAML persistence * refactor(config): remove redundant config APIs * refactor(config): remove unused config APIs * refactor(config): narrow profile APIs * fix(config): preserve profiles on invalid reorder * refactor(startup): narrow resolve helpers * refactor(config): unify mixed port defaults * refactor(network): simplify response APIs * refactor(config): make profile builders infallible * refactor(config): make profile activation infallible * refactor(api): simplify internal runtime APIs * refactor: consolidate internal config and window APIs
This commit is contained in:
@@ -263,7 +263,7 @@ impl CoreManager {
|
||||
crate::config::Config::notify_startup_mixed_port_fallback();
|
||||
return Err(start_error);
|
||||
}
|
||||
match crate::config::Config::retry_startup_mixed_port_fallback().await {
|
||||
match crate::config::Config::resolve_startup_mixed_port().await {
|
||||
Ok(true) => {
|
||||
retries += 1;
|
||||
logging!(
|
||||
|
||||
@@ -153,7 +153,7 @@ impl Timer {
|
||||
// Redundant with first_delay == ZERO, kept as the immediate path; mark_task_running
|
||||
// no-ops whichever of the two arrives second.
|
||||
let cur_timestamp = chrono::Local::now().timestamp();
|
||||
if let Some(items) = Config::profiles().await.data_arc().get_items() {
|
||||
if let Some(items) = Config::profiles().await.data_arc().items.as_ref() {
|
||||
for item in items.iter() {
|
||||
if let Some(option) = item.option.as_ref()
|
||||
&& option.allow_auto_update.unwrap_or(true)
|
||||
@@ -204,7 +204,7 @@ impl Timer {
|
||||
}
|
||||
|
||||
async fn gen_map(&self) -> HashMap<String, TaskSchedule> {
|
||||
if let Some(items) = Config::profiles().await.data_arc().get_items() {
|
||||
if let Some(items) = Config::profiles().await.data_arc().items.as_ref() {
|
||||
return Self::gen_map_from_items(items);
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ impl Timer {
|
||||
let task_interval = *self.timer_map.read().get(uid)?;
|
||||
let profiles = Config::profiles().await;
|
||||
let profiles_guard = profiles.latest_arc();
|
||||
let items = profiles_guard.get_items()?;
|
||||
let items = profiles_guard.items.as_ref()?;
|
||||
|
||||
let profile = items.iter().find(|item| item.uid.as_deref() == Some(uid))?;
|
||||
let updated = profile.updated.unwrap_or(0) as i64;
|
||||
|
||||
@@ -294,7 +294,7 @@ impl Tray {
|
||||
{
|
||||
let profiles = Config::profiles().await;
|
||||
let profiles = profiles.latest_arc();
|
||||
if let Some(current_profile_uid) = profiles.get_current()
|
||||
if let Some(current_profile_uid) = profiles.current.as_ref()
|
||||
&& let Ok(profile) = profiles.get_item(current_profile_uid)
|
||||
{
|
||||
current_profile_name = match &profile.name {
|
||||
|
||||
Reference in New Issue
Block a user