diff --git a/src-tauri/src/api_client.rs b/src-tauri/src/api_client.rs
index d199970..50710b4 100644
--- a/src-tauri/src/api_client.rs
+++ b/src-tauri/src/api_client.rs
@@ -315,7 +315,7 @@ pub struct ApiClient {
}
impl ApiClient {
- pub fn new() -> Self {
+ fn new() -> Self {
Self {
client: Client::new(),
firefox_api_base: "https://product-details.mozilla.org/1.0".to_string(),
@@ -327,6 +327,10 @@ impl ApiClient {
}
}
+ pub fn instance() -> &'static ApiClient {
+ &API_CLIENT
+ }
+
#[cfg(test)]
pub fn new_with_base_urls(
firefox_api_base: String,
@@ -1336,6 +1340,11 @@ impl ApiClient {
}
}
+// Global singleton instance
+lazy_static::lazy_static! {
+ static ref API_CLIENT: ApiClient = ApiClient::new();
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/src-tauri/src/app_auto_updater.rs b/src-tauri/src/app_auto_updater.rs
index 9e7f9df..bdde2a5 100644
--- a/src-tauri/src/app_auto_updater.rs
+++ b/src-tauri/src/app_auto_updater.rs
@@ -49,12 +49,16 @@ pub struct AppAutoUpdater {
}
impl AppAutoUpdater {
- pub fn new() -> Self {
+ fn new() -> Self {
Self {
client: Client::new(),
}
}
+ pub fn instance() -> &'static AppAutoUpdater {
+ &APP_AUTO_UPDATER
+ }
+
/// Check if running a nightly build based on environment variable
pub fn is_nightly_build() -> bool {
// If STABLE_RELEASE env var is set at compile time, it's a stable build
@@ -971,7 +975,7 @@ rm "{}"
#[tauri::command]
pub async fn check_for_app_updates() -> Result