Skip to content

Commit 2dd36ff

Browse files
committed
refactor: update scripting
1 parent 34a5b9f commit 2dd36ff

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

scripting/src/vtftk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export interface ItemModel {
207207
/**
208208
* Configuration for the item image
209209
*/
210-
image: ItemImageConfig;
210+
config: ItemConfig;
211211
/**
212212
* Order of the item within the UI
213213
*/

src-tauri/src/script/ops/vtftk.rs

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use std::{cell::RefCell, rc::Rc};
22

33
use crate::{
4-
database::entity::{items::ItemModel, sounds::SoundModel},
5-
overlay::{OverlayMessage, PartialItemModel},
4+
database::entity::{
5+
items::{ItemModel, ItemWithSounds},
6+
sounds::SoundModel,
7+
},
8+
overlay::OverlayMessage,
69
script::runtime::ScriptRuntimeDataExt,
710
};
811
use anyhow::Context;
@@ -32,20 +35,9 @@ pub async fn op_vtftk_get_items_by_names(
3235
state: Rc<RefCell<OpState>>,
3336
#[serde] names: Vec<String>,
3437
ignore_case: bool,
35-
) -> anyhow::Result<Vec<PartialItemModel>> {
38+
) -> anyhow::Result<Vec<ItemWithSounds>> {
3639
let db = state.db()?;
37-
let items: Vec<PartialItemModel> =
38-
ItemModel::get_by_names_with_sounds(&db, &names, ignore_case)
39-
.await?
40-
.into_iter()
41-
.map(|item| PartialItemModel {
42-
id: item.item.id,
43-
config: item.item.config,
44-
impact_sound_ids: item.impact_sounds_ids,
45-
windup_sound_ids: item.windup_sounds_ids,
46-
})
47-
.collect();
48-
40+
let items = ItemModel::get_by_names_with_sounds(&db, &names, ignore_case).await?;
4941
Ok(items)
5042
}
5143

@@ -55,18 +47,9 @@ pub async fn op_vtftk_get_items_by_names(
5547
pub async fn op_vtftk_get_items_by_ids(
5648
state: Rc<RefCell<OpState>>,
5749
#[serde] ids: Vec<Uuid>,
58-
) -> anyhow::Result<Vec<PartialItemModel>> {
50+
) -> anyhow::Result<Vec<ItemWithSounds>> {
5951
let db = state.db()?;
60-
let items: Vec<PartialItemModel> = ItemModel::get_by_ids_with_sounds(&db, &ids)
61-
.await?
62-
.into_iter()
63-
.map(|item| PartialItemModel {
64-
id: item.item.id,
65-
config: item.item.config,
66-
impact_sound_ids: item.impact_sounds_ids,
67-
windup_sound_ids: item.windup_sounds_ids,
68-
})
69-
.collect();
52+
let items = ItemModel::get_by_ids_with_sounds(&db, &ids).await?;
7053

7154
Ok(items)
7255
}

0 commit comments

Comments
 (0)