1
- use std:: collections:: BTreeMap ;
1
+ use std:: {
2
+ collections:: BTreeMap ,
3
+ ops:: { Deref , DerefMut } ,
4
+ } ;
2
5
3
6
use common:: enums:: Drivers ;
4
7
use leptos:: { RwSignal , SignalGet , SignalSet } ;
5
8
use tauri_sys:: tauri:: invoke;
6
9
7
10
use crate :: invoke:: { Invoke , InvokeProjectDbDeleteArgs , InvokeProjectDbInsertArgs } ;
8
11
12
+ use super :: BTreeStore ;
13
+
9
14
#[ derive( Clone , Copy , Debug ) ]
10
- pub struct ProjectsStore ( pub RwSignal < BTreeMap < String , String > > ) ;
15
+ pub struct ProjectsStore ( pub BTreeStore ) ;
11
16
12
17
impl Default for ProjectsStore {
13
18
fn default ( ) -> Self {
14
19
Self :: new ( )
15
20
}
16
21
}
17
22
23
+ impl Deref for ProjectsStore {
24
+ type Target = BTreeStore ;
25
+
26
+ fn deref ( & self ) -> & Self :: Target {
27
+ & self . 0
28
+ }
29
+ }
30
+
31
+ impl DerefMut for ProjectsStore {
32
+ fn deref_mut ( & mut self ) -> & mut Self :: Target {
33
+ & mut self . 0
34
+ }
35
+ }
36
+
18
37
impl ProjectsStore {
19
38
#[ must_use]
20
39
pub fn new ( ) -> Self {
21
40
Self ( RwSignal :: default ( ) )
22
41
}
23
42
24
43
pub fn select_project_by_name ( & self , project_id : & str ) -> Option < String > {
25
- self . 0 . get ( ) . get ( project_id) . cloned ( )
44
+ self . get ( ) . get ( project_id) . cloned ( )
26
45
}
27
46
28
47
pub fn select_driver_by_project ( & self , project_id : Option < & str > ) -> Drivers {
@@ -44,7 +63,7 @@ impl ProjectsStore {
44
63
let projects = invoke :: < _ , BTreeMap < String , String > > ( Invoke :: ProjectDbSelect . as_ref ( ) , & ( ) )
45
64
. await
46
65
. unwrap ( ) ;
47
- self . 0 . set ( projects) ;
66
+ self . set ( projects) ;
48
67
}
49
68
50
69
pub async fn insert_project ( & self , project_id : & str , project_details : & str ) {
0 commit comments