mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
* fix confirm * remove unnecessary lines * fix * change file
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"dialog": patch
|
||||
"dialog-js": patch
|
||||
---
|
||||
|
||||
Fix incorrect result for dialog messages.
|
||||
@@ -53,14 +53,8 @@ impl<R: Runtime> Dialog<R> {
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
macro_rules! run_dialog {
|
||||
($e:expr, $h: ident) => {{
|
||||
std::thread::spawn(move || {
|
||||
let response = tauri::async_runtime::block_on($e);
|
||||
$h(!matches!(
|
||||
response,
|
||||
rfd::MessageDialogResult::No | rfd::MessageDialogResult::Cancel
|
||||
));
|
||||
});
|
||||
($e:expr, $h: expr) => {{
|
||||
std::thread::spawn(move || $h(tauri::async_runtime::block_on($e)));
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -69,13 +63,7 @@ macro_rules! run_dialog {
|
||||
($e:expr, $h: ident) => {{
|
||||
std::thread::spawn(move || {
|
||||
let context = glib::MainContext::default();
|
||||
context.invoke_with_priority(glib::PRIORITY_HIGH, move || {
|
||||
let response = $e;
|
||||
$h(!matches!(
|
||||
response,
|
||||
rfd::MessageDialogResult::No | rfd::MessageDialogResult::Cancel
|
||||
));
|
||||
});
|
||||
context.invoke_with_priority(glib::PRIORITY_HIGH, move || $h($e));
|
||||
});
|
||||
}};
|
||||
}
|
||||
@@ -83,10 +71,7 @@ macro_rules! run_dialog {
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
macro_rules! run_file_dialog {
|
||||
($e:expr, $h: ident) => {{
|
||||
std::thread::spawn(move || {
|
||||
let response = tauri::async_runtime::block_on($e);
|
||||
$h(response);
|
||||
});
|
||||
std::thread::spawn(move || $h(tauri::async_runtime::block_on($e)));
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -95,10 +80,7 @@ macro_rules! run_file_dialog {
|
||||
($e:expr, $h: ident) => {{
|
||||
std::thread::spawn(move || {
|
||||
let context = glib::MainContext::default();
|
||||
context.invoke_with_priority(glib::PRIORITY_HIGH, move || {
|
||||
let response = $e;
|
||||
$h(response);
|
||||
});
|
||||
context.invoke_with_priority(glib::PRIORITY_HIGH, move || $h($e));
|
||||
});
|
||||
}};
|
||||
}
|
||||
@@ -226,5 +208,16 @@ pub fn show_message_dialog<R: Runtime, F: FnOnce(bool) + Send + 'static>(
|
||||
dialog: MessageDialogBuilder<R>,
|
||||
f: F,
|
||||
) {
|
||||
use rfd::MessageDialogResult;
|
||||
|
||||
let ok_label = dialog.ok_button_label.clone();
|
||||
let f = move |res| {
|
||||
f(match res {
|
||||
MessageDialogResult::Ok | MessageDialogResult::Yes => true,
|
||||
MessageDialogResult::Custom(s) => ok_label.map_or(s == OK, |ok_label| ok_label == s),
|
||||
_ => false,
|
||||
});
|
||||
};
|
||||
|
||||
run_dialog!(MessageDialog::from(dialog).show(), f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user