[WIP] Fix tauri notifications
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use log::LevelFilter;
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Warn;
|
||||
// #[cfg(not(debug_assertions))]
|
||||
// const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Warn;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
// #[cfg(debug_assertions)]
|
||||
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Debug;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -43,8 +43,8 @@ pub fn parse(raw: impl IntoIterator<Item = impl Into<std::ffi::OsString>>) -> Cl
|
||||
data: None,
|
||||
log_level: DEFAULT_LOG_LEVEL,
|
||||
background: false,
|
||||
with_prompts: false,
|
||||
with_notifications: false,
|
||||
with_prompts: true,
|
||||
with_notifications: true,
|
||||
};
|
||||
|
||||
let raw = clap_lex::RawArgs::new(raw);
|
||||
@@ -67,11 +67,11 @@ pub fn parse(raw: impl IntoIterator<Item = impl Into<std::ffi::OsString>>) -> Cl
|
||||
Ok("background") => {
|
||||
cli.background = true;
|
||||
}
|
||||
Ok("with_prompts") => {
|
||||
cli.with_prompts = true;
|
||||
Ok("no-prompts") => {
|
||||
cli.with_prompts = false;
|
||||
}
|
||||
Ok("with_notifications") => {
|
||||
cli.with_notifications = true;
|
||||
Ok("no-notifications") => {
|
||||
cli.with_notifications = false;
|
||||
}
|
||||
_ => {
|
||||
// Ignore unexpected flags
|
||||
|
||||
@@ -127,14 +127,14 @@ fn main() {
|
||||
let cli_args = cli::parse(std::env::args());
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let log_target = if let Some(data_dir) = cli_args.data {
|
||||
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Folder {
|
||||
path: Path::new(&format!("{}/logs/app2", data_dir)).into(),
|
||||
file_name: None,
|
||||
})
|
||||
} else {
|
||||
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stdout)
|
||||
};
|
||||
let log_target = tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stdout);
|
||||
// let log_target = if let Some(data_dir) = cli_args.data {
|
||||
// tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Folder {
|
||||
// path: Path::new(&format!("{}/logs/app2", data_dir)).into(),
|
||||
// file_name: None,
|
||||
// })
|
||||
// } else {
|
||||
// };
|
||||
|
||||
// TODO(vladimir): Permission for logs/app2 folder are not guaranteed. Use the default location for now.
|
||||
#[cfg(target_os = "windows")]
|
||||
|
||||
@@ -2,6 +2,7 @@ use crate::portapi::client::*;
|
||||
use crate::portapi::message::*;
|
||||
use crate::portapi::models::notification::*;
|
||||
use crate::portapi::types::*;
|
||||
use log::debug;
|
||||
use log::error;
|
||||
use serde_json::json;
|
||||
use tauri::async_runtime;
|
||||
@@ -25,12 +26,12 @@ pub async fn notification_handler(cli: PortAPI) {
|
||||
Ok(n) => {
|
||||
// Skip if this one should not be shown using the system notifications
|
||||
if !n.show_on_system {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip if this action has already been acted on
|
||||
if n.selected_action_id.is_empty() {
|
||||
return;
|
||||
if !n.selected_action_id.is_empty() {
|
||||
continue;
|
||||
}
|
||||
show_notification(&cli, key, n).await;
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
"takesValue": true
|
||||
},
|
||||
{
|
||||
"name": "with-notifications",
|
||||
"description": "Enable experimental notifications via Tauri. Replaces the notifier app."
|
||||
"name": "no-notifications",
|
||||
"description": "Disable notifications via Tauri."
|
||||
},
|
||||
{
|
||||
"name": "with-prompts",
|
||||
"description": "Enable experimental prompt support via Tauri. Replaces the notifier app."
|
||||
"name": "no-prompts",
|
||||
"description": "Disable prompt support via Tauri."
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user