[WIP] Fix tauri notifications

This commit is contained in:
Vladimir Stoilov 2024-12-03 17:28:40 +02:00
parent d15ede9f53
commit 5ae261f062
No known key found for this signature in database
GPG key ID: 2F190B67A43A81AF
7 changed files with 39 additions and 35 deletions

View file

@ -474,10 +474,11 @@ tauri-build:
# Binaries
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster"
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster.exe" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster.exe"
# SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/WebView2Loader.dll" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/WebView2Loader.dll"
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/WebView2Loader.dll" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/WebView2Loader.dll"
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster" ./output/portmaster
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster.exe" ./output/portmaster.exe
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/WebView2Loader.dll" ./output/WebView2Loader.dll
tauri-release:
@ -517,9 +518,11 @@ release-prep:
# Windows specific
COPY (+tauri-build/output/portmaster.exe --target="x86_64-pc-windows-gnu") ./output/binary/windows_amd64/portmaster.exe
COPY (+tauri-build/output/WebView2Loader.dll --target="x86_64-pc-windows-gnu") ./output/binary/windows_amd64/WebView2Loader.dll
COPY (+go-build/output/portmaster-core.exe --GOARCH=amd64 --GOOS=windows --CMDS=portmaster-core) ./output/binary/windows_amd64/portmaster-core.exe
# TODO(vladimir): figure out a way to get the lastest release of the kext.
RUN touch ./output/binary/windows_amd64/portmaster-kext.sys
# TODO(vladimir): figure out a way to get the lastest release of the kext and dll.
RUN wget -O ./output/binary/windows_amd64/portmaster-kext.sys https://updates.safing.io/windows_amd64/kext/portmaster-kext_v2-0-4.sys
RUN touch ./output/binary/windows_amd64/portmaster-core.dll
# All platforms
COPY (+assets/assets.zip) ./output/binary/all/assets.zip

View file

@ -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

View file

@ -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")]

View file

@ -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;
}

View file

@ -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."
},
]
}

View file

@ -37,7 +37,7 @@ func (i *OSIntegration) Initialize() error {
return nil
}
// CleanUp releases any resourses allocated during initializaion.
// CleanUp releases any resources allocated during initialization.
func (i *OSIntegration) CleanUp() error {
if i.os.dll != nil {
return i.os.dll.Release()

View file

@ -238,14 +238,14 @@ func updateListIndex() error {
func ResolveListIDs(ids []string) ([]string, error) {
index, err := getListIndexFromCache()
if err != nil {
if errors.Is(err, database.ErrNotFound) {
if err := updateListIndex(); err != nil {
return nil, err
}
// if errors.Is(err, database.ErrNotFound) {
// if err := updateListIndex(); err != nil {
// return nil, err
// }
// retry resolving IDs
return ResolveListIDs(ids)
}
// // retry resolving IDs
// return ResolveListIDs(ids)
// }
log.Errorf("failed to resolved ids %v: %s", ids, err)
return nil, err