1
1
use std:: { cell:: RefCell , rc:: Rc } ;
2
2
3
3
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 ,
6
9
script:: runtime:: ScriptRuntimeDataExt ,
7
10
} ;
8
11
use anyhow:: Context ;
@@ -32,20 +35,9 @@ pub async fn op_vtftk_get_items_by_names(
32
35
state : Rc < RefCell < OpState > > ,
33
36
#[ serde] names : Vec < String > ,
34
37
ignore_case : bool ,
35
- ) -> anyhow:: Result < Vec < PartialItemModel > > {
38
+ ) -> anyhow:: Result < Vec < ItemWithSounds > > {
36
39
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 ?;
49
41
Ok ( items)
50
42
}
51
43
@@ -55,18 +47,9 @@ pub async fn op_vtftk_get_items_by_names(
55
47
pub async fn op_vtftk_get_items_by_ids (
56
48
state : Rc < RefCell < OpState > > ,
57
49
#[ serde] ids : Vec < Uuid > ,
58
- ) -> anyhow:: Result < Vec < PartialItemModel > > {
50
+ ) -> anyhow:: Result < Vec < ItemWithSounds > > {
59
51
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 ?;
70
53
71
54
Ok ( items)
72
55
}
0 commit comments