11use std:: path:: { Path , PathBuf } ;
2-
32use tauri:: { App , Manager } ;
43
54use crate :: {
@@ -9,24 +8,21 @@ use crate::{
98 versioning:: { self , UpdateFeatures } ,
109} ;
1110
11+ #[ cfg( target_os = "linux" ) ]
12+ use dialog:: DialogBox ;
13+ #[ cfg( not( target_os = "linux" ) ) ]
14+ use tauri_plugin_dialog:: { DialogExt , MessageDialogButtons , MessageDialogKind } ;
15+
1216pub fn run_app_startup ( app : & App ) -> Result < Vec < UpdateFeatures > > {
1317 let handle = app. handle ( ) ;
1418
1519 let update_features: Vec < UpdateFeatures > =
1620 match versioning:: handle_updates_get_features ( handle, false ) {
1721 Err ( error) => match error {
1822 Error :: OutdatedVersion { .. } => {
19- let should_quit = util:: show_prompt_dialog (
20- app,
21- format ! (
22- "{error}\n Would you like to quit and avoid potential storage issues?"
23- ) ,
24- "OpenHome Version Error" ,
25- "Quit" ,
26- "Launch App Anyways" ,
27- ) ;
28-
29- if should_quit {
23+ let should_launch = show_version_error_prompt ( app, & error) ;
24+
25+ if should_launch {
3026 return Err ( error) ;
3127 }
3228
@@ -115,3 +111,26 @@ fn set_theme_from_settings(app: &App) -> Result<()> {
115111 . set_theme ( theme_option)
116112 . map_err ( |e| Error :: other_with_source ( "Could not set theme" , e) )
117113}
114+
115+ pub fn show_version_error_prompt ( _app : & tauri:: App , error : & Error ) -> bool {
116+ #[ cfg( not( target_os = "linux" ) ) ]
117+ return !_app
118+ . dialog ( )
119+ . message ( error. to_string ( ) )
120+ . title ( "OpenHome Version Error" )
121+ . kind ( MessageDialogKind :: Error )
122+ . buttons ( MessageDialogButtons :: OkCancelCustom (
123+ "Quit" . to_owned ( ) ,
124+ "Launch App Anyways" . to_owned ( ) ,
125+ ) )
126+ . blocking_show ( ) ;
127+
128+ #[ cfg( target_os = "linux" ) ]
129+ dialog:: Question :: new ( format ! (
130+ "{error}\n Do you want to accept the risk and launch anyways?"
131+ ) )
132+ . title ( "OpenHome Version Error" )
133+ . show ( )
134+ . expect ( "Could not display dialog box" )
135+ . eq ( & dialog:: Choice :: Yes )
136+ }
0 commit comments