Skip to content

Commit

Permalink
fix: update merge function
Browse files Browse the repository at this point in the history
  • Loading branch information
shonya3 committed Jul 28, 2023
1 parent 3f5ce36 commit a933b20
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/app/src-tauri/lib/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use tokio::sync::Mutex;

use divi::{
league::TradeLeague,
prices::Prices,
sample::{CardNameAmount, DivinationCardsSample, SampleData},
};
use tauri::{command, AppHandle, Manager, State};
use tauri::{command, State};

use crate::{js_result::JSResult, prices::AppCardPrices};

Expand Down Expand Up @@ -40,9 +39,11 @@ pub async fn sample_cards(
#[command]
pub async fn merge(
samples: Vec<DivinationCardsSample>,
app_handle: AppHandle,
) -> DivinationCardsSample {
DivinationCardsSample::merge(Some(app_handle.state::<Prices>().inner().clone()), &samples)
state: State<'_, Mutex<AppCardPrices>>,
) -> Result<DivinationCardsSample, ()> {
let mut guard = state.lock().await;
let prices = guard.get_or_update(&TradeLeague::default()).await;
Ok(DivinationCardsSample::merge(Some(prices), &samples))
}

#[command]
Expand Down

0 comments on commit a933b20

Please sign in to comment.