@@ -73,6 +73,7 @@ pub struct Config {
7373 pub auto_update_checker : bool ,
7474 pub notifications : bool ,
7575 pub track_view_density : TrackViewDensity ,
76+ pub wayland_compat : bool ,
7677}
7778
7879pub const SYSTEM_THEME : & str = "__system" ;
@@ -98,6 +99,7 @@ impl Config {
9899 auto_update_checker : true ,
99100 notifications : false ,
100101 track_view_density : TrackViewDensity :: Normal ,
102+ wayland_compat : false ,
101103 }
102104 }
103105}
@@ -108,6 +110,15 @@ pub struct ConfigManager {
108110 pub data : RwLock < Config > ,
109111}
110112
113+ impl ConfigManager {
114+ pub fn new ( manager : HomeConfig , config : Config ) -> Self {
115+ Self {
116+ manager,
117+ data : RwLock :: new ( config) ,
118+ }
119+ }
120+ }
121+
111122fn config_err < T : Display > ( err : T ) -> MuseeksError {
112123 MuseeksError :: Config ( format ! ( "{}" , err) )
113124}
@@ -167,30 +178,7 @@ pub fn set_config(config_manager: State<ConfigManager>, config: Config) -> AnyRe
167178 config_manager. update ( config)
168179}
169180
170- pub fn init < R : Runtime > ( ) -> TauriPlugin < R > {
171- let conf_path = get_storage_dir ( ) ;
172- let manager = HomeConfig :: with_file ( conf_path. join ( "config.toml" ) ) ;
173- let existing_config = manager. toml :: < Config > ( ) ;
174-
175- let config = match existing_config {
176- Ok ( config) => ConfigManager {
177- manager,
178- data : RwLock :: new ( config) ,
179- } ,
180- Err ( _) => {
181- // The config does not exist, so let's instantiate it with defaults
182- // Potential issue: if the config is extended, the defaults will be
183- // reloaded
184- let default_config = Config :: default ( ) ;
185- manager. save_toml ( & default_config) . unwrap ( ) ;
186-
187- ConfigManager {
188- manager,
189- data : RwLock :: new ( default_config) ,
190- }
191- }
192- } ;
193-
181+ pub fn init < R : Runtime > ( config : ConfigManager ) -> TauriPlugin < R > {
194182 // We need to inject the initial state of the config to the window object of
195183 // our webview, because some of our front-end modules are instantiated at
196184 // parsing time and require data that would otherwise only load-able asynchronously
0 commit comments