1- use std:: collections:: BTreeMap ;
1+ use std:: {
2+ collections:: BTreeMap ,
3+ ops:: { Deref , DerefMut } ,
4+ } ;
25
36use common:: enums:: Drivers ;
47use leptos:: { RwSignal , SignalGet , SignalSet } ;
58use tauri_sys:: tauri:: invoke;
69
710use crate :: invoke:: { Invoke , InvokeProjectDbDeleteArgs , InvokeProjectDbInsertArgs } ;
811
12+ use super :: BTreeStore ;
13+
914#[ derive( Clone , Copy , Debug ) ]
10- pub struct ProjectsStore ( pub RwSignal < BTreeMap < String , String > > ) ;
15+ pub struct ProjectsStore ( pub BTreeStore ) ;
1116
1217impl Default for ProjectsStore {
1318 fn default ( ) -> Self {
1419 Self :: new ( )
1520 }
1621}
1722
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+
1837impl ProjectsStore {
1938 #[ must_use]
2039 pub fn new ( ) -> Self {
2140 Self ( RwSignal :: default ( ) )
2241 }
2342
2443 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 ( )
2645 }
2746
2847 pub fn select_driver_by_project ( & self , project_id : Option < & str > ) -> Drivers {
@@ -44,7 +63,7 @@ impl ProjectsStore {
4463 let projects = invoke :: < _ , BTreeMap < String , String > > ( Invoke :: ProjectDbSelect . as_ref ( ) , & ( ) )
4564 . await
4665 . unwrap ( ) ;
47- self . 0 . set ( projects) ;
66+ self . set ( projects) ;
4867 }
4968
5069 pub async fn insert_project ( & self , project_id : & str , project_details : & str ) {
0 commit comments