mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-07-25 01:13:57 +10:00
feat(cache): Added offline!() macro to manage online and offline function distinctions
See fetch_library command for example
This commit is contained in:
@@ -60,9 +60,10 @@ use tauri::{AppHandle, Manager, RunEvent, WindowEvent};
|
|||||||
use tauri_plugin_deep_link::DeepLinkExt;
|
use tauri_plugin_deep_link::DeepLinkExt;
|
||||||
use tauri_plugin_dialog::DialogExt;
|
use tauri_plugin_dialog::DialogExt;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Serialize)]
|
#[derive(Clone, Copy, Serialize, Eq, PartialEq)]
|
||||||
pub enum AppStatus {
|
pub enum AppStatus {
|
||||||
NotConfigured,
|
NotConfigured,
|
||||||
|
Offline,
|
||||||
ServerError,
|
ServerError,
|
||||||
SignedOut,
|
SignedOut,
|
||||||
SignedIn,
|
SignedIn,
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! offline {
|
macro_rules! offline {
|
||||||
($var:expr, $func1:expr, $func2:expr, $( $arg:expr ),* ) => {
|
($var:expr, $func1:expr, $func2:expr, $( $arg:expr ),* ) => {
|
||||||
if borrow_db_checked().settings.offline || state.{
|
|
||||||
|
if crate::borrow_db_checked().settings.force_offline || $var.lock().unwrap().status == crate::AppStatus::Offline {
|
||||||
$func1( $( $arg ), *)
|
$func1( $( $arg ), *)
|
||||||
} else {
|
} else {
|
||||||
$func2( $( $arg ), *)
|
$func2( $( $arg ), *)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,7 @@ export type Game = {
|
|||||||
|
|
||||||
export enum AppStatus {
|
export enum AppStatus {
|
||||||
NotConfigured = "NotConfigured",
|
NotConfigured = "NotConfigured",
|
||||||
|
Offline = "Offline",
|
||||||
SignedOut = "SignedOut",
|
SignedOut = "SignedOut",
|
||||||
SignedIn = "SignedIn",
|
SignedIn = "SignedIn",
|
||||||
SignedInNeedsReauth = "SignedInNeedsReauth",
|
SignedInNeedsReauth = "SignedInNeedsReauth",
|
||||||
|
|||||||
Reference in New Issue
Block a user