Skip to content

Commit

Permalink
Fix once
Browse files Browse the repository at this point in the history
  • Loading branch information
arctixdev committed Aug 8, 2023
1 parent 7c9d12c commit 73eaef2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use tauri::api::process::Command;
use tauri::{utils::config::AppUrl, window::WindowBuilder, WindowUrl};
use std::sync::Once;

static DISCORD_RPC_STARTER: Once = Once::new();
static SQUEEZELITE_STARTER: Once = Once::new();

// Set the IS_WINDOWS constant to true if the target OS is windows
#[cfg(target_os = "windows")]
const IS_WINDOWS: bool = true;
Expand All @@ -16,7 +19,7 @@ const IS_WINDOWS: bool = false;
#[tauri::command]
fn start_rpc(websocket: String) {
// To prevent it from starting multiple times even if frontend gets reloaded
Once::new().call_once(|| {
DISCORD_RPC_STARTER.call_once(|| {
// Start the discord rich presence manager in a new thread
thread::spawn(move || {
let hostname: std::ffi::OsString = gethostname();
Expand All @@ -28,7 +31,7 @@ fn start_rpc(websocket: String) {
#[tauri::command]
fn start_sqzlite(ip: String) {
// To prevent it from starting multiple times even if frontend gets reloaded
Once::new().call_once(|| {
SQUEEZELITE_STARTER.call_once(|| {
// Start squeezelite in a new thread
thread::spawn(move || {
let hostname: std::ffi::OsString = gethostname();
Expand Down

0 comments on commit 73eaef2

Please sign in to comment.