Skip to content

Commit

Permalink
os notifications + delay window showing
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Oct 31, 2024
1 parent 9a5cf69 commit eaa4f39
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 32 deletions.
171 changes: 166 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ tauri-plugin-process = "2.0.0"
tauri-plugin-decorum = "1.0.0"
tauri-plugin-dialog = "2.0.0"
tauri-plugin-updater = "2.0.0"
tauri-plugin-notification = "2.0.0"
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "v2" }
tauri-plugin-global-shortcut = "2.0.0"
tauri-specta = { version = "=2.0.0-rc.20", features = ["derive", "typescript"] }
Expand Down
32 changes: 16 additions & 16 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use std::{
};
use tauri::{AppHandle, Manager, Runtime, State, WindowEvent};
use tauri_nspanel::ManagerExt;
use tauri_plugin_notification::NotificationExt;
use tauri_plugin_shell::ShellExt;
use tauri_specta::Event;
use tokio::task;
Expand Down Expand Up @@ -360,6 +361,10 @@ async fn start_recording(app: AppHandle, state: MutableState<'_, App>) -> Result
if let Some(window) = (CapWindow::InProgressRecording { position: None }).get(&app) {
window.eval("window.location.reload()").unwrap();
window.show().unwrap();
} else {
CapWindow::InProgressRecording { position: None }
.show(&app)
.ok();
}

AppSounds::StartRecording.play();
Expand Down Expand Up @@ -1470,16 +1475,16 @@ async fn remove_fake_window(
Ok(())
}

#[tauri::command(async)]
#[specta::specta]
fn show_notifications_window(app: AppHandle) {
if app.get_webview_window("notifications").is_some() {
println!("notifications window already exists");
return;
}
// #[tauri::command(async)]
// #[specta::specta]
// fn show_notifications_window(app: AppHandle) {
// if app.get_webview_window("notifications").is_some() {
// println!("notifications window already exists");
// return;
// }

CapWindow::Notifications.show(&app).unwrap();
}
// CapWindow::Notifications.show(&app).unwrap();
// }

#[tauri::command(async)]
#[specta::specta]
Expand Down Expand Up @@ -2345,7 +2350,7 @@ pub async fn run() {
list_capture_screens,
list_audio_devices,
show_previous_recordings_window,
show_notifications_window,
// show_notifications_window,
close_previous_recordings_window,
set_fake_window_bounds,
remove_fake_window,
Expand Down Expand Up @@ -2437,6 +2442,7 @@ pub async fn run() {
.plugin(tauri_plugin_oauth::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_notification::init())
.plugin(flags::plugin::init())
.invoke_handler(specta_builder.invoke_handler())
.setup(move |app| {
Expand Down Expand Up @@ -2552,12 +2558,6 @@ pub async fn run() {
});
});

let app_handle_clone = app_handle.clone();
tauri::async_runtime::spawn(async move {
tokio::time::sleep(Duration::from_secs(5)).await;
AuthenticationInvalid.emit(&app_handle_clone).ok();
});

let app_handle_clone = app_handle.clone();
AuthenticationInvalid::listen_any(app, move |_| {
let app_handle = app_handle_clone.clone();
Expand Down
Loading

1 comment on commit eaa4f39

@vercel
Copy link

@vercel vercel bot commented on eaa4f39 Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.