fix: enforce only one instance of the app
All checks were successful
FanslySync Build & Test / FanslySync Test Runner (push) Successful in 11m51s

This commit is contained in:
Sticks
2025-04-23 20:20:39 -04:00
parent f4565ab580
commit d4d9d2ebce
5 changed files with 28 additions and 2 deletions

View File

@ -1,3 +1,4 @@
use crate::handlers::fansly::{SyncProgress, PROGRESS};
use crate::{
handlers::fansly::Fansly,
structs::{FanslyAccountResponse, FanslyBaseResponse, SyncDataResponse},
@ -5,7 +6,6 @@ use crate::{
use lazy_static::lazy_static;
use serde_json::Value;
use tokio::sync::Mutex;
use crate::handlers::fansly::{SyncProgress, PROGRESS};
lazy_static! {
static ref FANSLY: Mutex<Fansly> = Mutex::new(Fansly::new(None));

View File

@ -404,7 +404,6 @@ impl Fansly {
"[sync::process] Got {} followers from API.",
response.response.len()
);
// Collect followers
for follower in response.response.clone() {

View File

@ -20,6 +20,8 @@ use tauri::tray::TrayIconBuilder;
use tauri::AppHandle;
use tauri::Manager;
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_dialog::DialogExt;
use tauri_plugin_dialog::MessageDialogKind;
use tauri_plugin_log::{Target, TargetKind};
fn get_log_path() -> io::Result<String> {
@ -108,6 +110,14 @@ async fn main() {
.max_file_size(1024 * 1024 * 5)
.build(),
)
.plugin(tauri_plugin_single_instance::init(|app,_args,_cwd| {
// Show a dialog if the app is already running
app.dialog()
.message("FanslySync is already running in the background. Please left click the tray icon -> Show Window to open the app.")
.title("FanslySync")
.kind(MessageDialogKind::Warning)
.blocking_show();
}))
.invoke_handler(tauri::generate_handler![
init_config,
get_config,