Skip to content

Commit

Permalink
Replace "macos" with "app-close" plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Mar 17, 2024
1 parent 1a096db commit a72d8a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async fn main() {

tauri::Builder::default()
// Custom integrations
.plugin(plugins::app_close::init())
.plugin(plugins::app_menu::init())
.plugin(plugins::config::init())
.plugin(plugins::cover::init())
Expand All @@ -28,7 +29,6 @@ async fn main() {
.plugin(plugins::default_view::init())
.plugin(plugins::shell_extension::init())
.plugin(plugins::sleepblocker::init())
.plugin(plugins::macos::init())
// Tauri integrations with the Operating System
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_os::init())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use tauri::plugin::{Builder, TauriPlugin};
use tauri::{Manager, Runtime};
use tauri::Runtime;

/**
* Plugin in charge on making sure closing the app does not stop the audio
*/
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::<R>::new("sleepblocker")
Builder::<R>::new("app-close")
.on_window_ready(|win| {
// Prevent macOS to kill the player when closing the main window. Instead,
// the window should be hidden and re-shown when invoking it again.
#[cfg(target_os = "macos")]
{
use tauri::Manager as _; // Suppress warning about unused import.

// Weird, should "win" be a reference instead maybe?
let window = win.clone();

Expand All @@ -22,6 +24,9 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
_ => {}
});
}
// TODO: Implement the same for Windows and Linux if needed.
#[cfg(not(target_os = "macos"))]
drop(win); // Suppress warning about unused variable.
})
.build()
}
6 changes: 1 addition & 5 deletions src-tauri/src/plugins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod debug;
/**
* Core features
*/
pub mod app_close;
pub mod app_menu;
pub mod cover;
pub mod shell_extension;
Expand All @@ -24,8 +25,3 @@ pub mod database;
*/
pub mod default_view;
pub mod sleepblocker;

/**
* OS-specific plugins
*/
pub mod macos;

0 comments on commit a72d8a9

Please sign in to comment.