mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-08-15 19:00:23 +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"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
macro_rules! run_dialog {
|
macro_rules! run_dialog {
|
||||||
($e:expr, $h: ident) => {{
|
($e:expr, $h: expr) => {{
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || $h(tauri::async_runtime::block_on($e)));
|
||||||
let response = tauri::async_runtime::block_on($e);
|
|
||||||
$h(!matches!(
|
|
||||||
response,
|
|
||||||
rfd::MessageDialogResult::No | rfd::MessageDialogResult::Cancel
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,13 +63,7 @@ macro_rules! run_dialog {
|
|||||||
($e:expr, $h: ident) => {{
|
($e:expr, $h: ident) => {{
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let context = glib::MainContext::default();
|
let context = glib::MainContext::default();
|
||||||
context.invoke_with_priority(glib::PRIORITY_HIGH, move || {
|
context.invoke_with_priority(glib::PRIORITY_HIGH, move || $h($e));
|
||||||
let response = $e;
|
|
||||||
$h(!matches!(
|
|
||||||
response,
|
|
||||||
rfd::MessageDialogResult::No | rfd::MessageDialogResult::Cancel
|
|
||||||
));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
@@ -83,10 +71,7 @@ macro_rules! run_dialog {
|
|||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
macro_rules! run_file_dialog {
|
macro_rules! run_file_dialog {
|
||||||
($e:expr, $h: ident) => {{
|
($e:expr, $h: ident) => {{
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || $h(tauri::async_runtime::block_on($e)));
|
||||||
let response = tauri::async_runtime::block_on($e);
|
|
||||||
$h(response);
|
|
||||||
});
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,10 +80,7 @@ macro_rules! run_file_dialog {
|
|||||||
($e:expr, $h: ident) => {{
|
($e:expr, $h: ident) => {{
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let context = glib::MainContext::default();
|
let context = glib::MainContext::default();
|
||||||
context.invoke_with_priority(glib::PRIORITY_HIGH, move || {
|
context.invoke_with_priority(glib::PRIORITY_HIGH, move || $h($e));
|
||||||
let response = $e;
|
|
||||||
$h(response);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
@@ -226,5 +208,16 @@ pub fn show_message_dialog<R: Runtime, F: FnOnce(bool) + Send + 'static>(
|
|||||||
dialog: MessageDialogBuilder<R>,
|
dialog: MessageDialogBuilder<R>,
|
||||||
f: F,
|
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);
|
run_dialog!(MessageDialog::from(dialog).show(), f);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user