File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { LazyStore } from "@tauri-apps/plugin-store" ;
1
2
import { create } from "zustand" ;
2
3
import { combine } from "zustand/middleware" ;
3
4
5
+ const store = new LazyStore ( "settings.json" ) ;
6
+
4
7
export const useStore = create (
5
8
combine (
6
9
{
@@ -29,8 +32,22 @@ export const useStore = create(
29
32
set ( { networkConnected } ) ,
30
33
setNetworks : ( networks : string [ ] ) => set ( { networks } ) ,
31
34
setPlatformArch : ( platformArch : string ) => set ( { platformArch } ) ,
32
- setWalletshieldListenAddress : ( walletshieldListenAddress : string ) =>
33
- set ( { walletshieldListenAddress } ) ,
35
+
36
+ setWalletshieldListenAddress : async (
37
+ walletshieldListenAddress : string ,
38
+ ) => {
39
+ set ( { walletshieldListenAddress } ) ;
40
+ await store . set ( "walletshieldListenAddress" , walletshieldListenAddress ) ;
41
+ await store . save ( ) ;
42
+ } ,
43
+
44
+ loadPersistedSettings : async ( ) => {
45
+ const wla = await store . get < string > ( "walletshieldListenAddress" ) ;
46
+ if ( wla ) set ( { walletshieldListenAddress : wla } ) ;
47
+ } ,
34
48
} ) ,
35
49
) ,
36
50
) ;
51
+
52
+ // Load persisted settings on app start
53
+ useStore . getState ( ) . loadPersistedSettings ( ) ;
You can’t perform that action at this time.
0 commit comments