fix: disable Linux desktop notifications to avoid tokio runtime panic
This commit is contained in:
parent
18d26d7431
commit
e0b09e4c29
2 changed files with 20 additions and 3 deletions
|
|
@ -17,9 +17,12 @@ pub struct AppState {
|
|||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_notification::init())
|
||||
let builder = tauri::Builder::default().plugin(tauri_plugin_dialog::init());
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let builder = builder.plugin(tauri_plugin_notification::init());
|
||||
|
||||
builder
|
||||
.setup(|app| {
|
||||
let db_dir = app.path().app_data_dir()?;
|
||||
std::fs::create_dir_all(&db_dir)?;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,21 @@ type NewNotificationEvent = {
|
|||
notification: OrchaiNotification;
|
||||
};
|
||||
|
||||
function shouldSkipSystemNotification(): boolean {
|
||||
if (typeof navigator === "undefined") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Workaround: tauri-plugin-notification on Linux can panic in Tokio runtime
|
||||
// (notify-rust/zbus `block_on` inside async runtime). Keep in-app notifications only.
|
||||
return navigator.userAgent.toLowerCase().includes("linux");
|
||||
}
|
||||
|
||||
async function showSystemNotification(notification: OrchaiNotification) {
|
||||
if (shouldSkipSystemNotification()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
let permissionGranted = await isPermissionGranted();
|
||||
if (!permissionGranted) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue