Skip to content

Commit a933b20

Browse files
committed
fix: update merge function
1 parent 3f5ce36 commit a933b20

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/app/src-tauri/lib/src/commands.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use tokio::sync::Mutex;
22

33
use divi::{
44
league::TradeLeague,
5-
prices::Prices,
65
sample::{CardNameAmount, DivinationCardsSample, SampleData},
76
};
8-
use tauri::{command, AppHandle, Manager, State};
7+
use tauri::{command, State};
98

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

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

4849
#[command]

0 commit comments

Comments
 (0)