Skip to content

Commit

Permalink
fix: result
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzgydi committed Mar 2, 2022
1 parent f260d5d commit bcdae11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src-tauri/src/core/clash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ impl Clash {
let info = self.info.clone();
let mut config = self.config.clone();

// generate the payload
let payload = profiles.gen_enhanced()?;

win.once(&event_name, move |event| {
if let Some(result) = event.payload() {
let gen_map: Mapping = serde_json::from_str(result).unwrap();
Expand All @@ -312,9 +315,6 @@ impl Clash {
}
});

// generate the payload
let payload = profiles.gen_enhanced();

tauri::async_runtime::spawn(async move {
sleep(Duration::from_secs(5)).await;
win.emit("script-handler", payload).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/core/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ impl Profiles {
}

/// gen the enhanced profiles
pub fn gen_enhanced(&self) -> PrfEnhanced {
let current = self.gen_activate().unwrap();
pub fn gen_enhanced(&self) -> Result<PrfEnhanced> {
let current = self.gen_activate()?;

let chain = match self.chain.as_ref() {
Some(chain) => chain
Expand All @@ -454,7 +454,7 @@ impl Profiles {
None => vec![],
};

PrfEnhanced { current, chain }
Ok(PrfEnhanced { current, chain })
}
}

Expand Down

0 comments on commit bcdae11

Please sign in to comment.