Skip to content

Commit 764ed78

Browse files
Merge branch 'fix-linux-launch'
2 parents c3ef513 + ef30ae0 commit 764ed78

File tree

2 files changed

+32
-40
lines changed

2 files changed

+32
-40
lines changed

src-tauri/src/startup.rs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::path::{Path, PathBuf};
2-
32
use tauri::{App, Manager};
43

54
use 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+
1216
pub 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}\nWould 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}\nDo 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+
}

src-tauri/src/util.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::error::{Error, Result};
1414
#[cfg(target_os = "linux")]
1515
use dialog::DialogBox;
1616
#[cfg(not(target_os = "linux"))]
17-
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind};
17+
use tauri_plugin_dialog::{DialogExt, MessageDialogKind};
1818

1919
#[derive(serde::Serialize, serde::Deserialize, Debug)]
2020
pub struct ImageResponse {
@@ -320,30 +320,3 @@ pub fn show_error_dialog(_app: &tauri::App, message: impl Into<String>, title: i
320320
.show()
321321
.expect("Could not display dialog box");
322322
}
323-
324-
pub fn show_prompt_dialog(
325-
_app: &tauri::App,
326-
message: impl Into<String>,
327-
title: impl Into<String>,
328-
_yes: impl Into<String>,
329-
_no: impl Into<String>,
330-
) -> bool {
331-
#[cfg(not(target_os = "linux"))]
332-
return _app
333-
.dialog()
334-
.message(message)
335-
.title(title)
336-
.kind(MessageDialogKind::Error)
337-
.buttons(MessageDialogButtons::OkCancelCustom(
338-
_yes.into(),
339-
_no.into(),
340-
))
341-
.blocking_show();
342-
343-
#[cfg(target_os = "linux")]
344-
dialog::Question::new(message)
345-
.title(title)
346-
.show()
347-
.expect("Could not display dialog box")
348-
.eq(&dialog::Choice::Yes)
349-
}

0 commit comments

Comments
 (0)