mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-16 17:51:23 +10:00
refactor(game status): transient vs synced state now defined
This commit is contained in:
31
src-tauri/src/state.rs
Normal file
31
src-tauri/src/state.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
db::{GameStatus, GameTransientStatus},
|
||||
DB,
|
||||
};
|
||||
|
||||
pub type GameStatusWithTransient = (
|
||||
Option<GameStatus>,
|
||||
Option<GameTransientStatus>,
|
||||
);
|
||||
pub struct GameStatusManager {}
|
||||
|
||||
impl GameStatusManager {
|
||||
pub fn fetch_state(game_id: &String) -> GameStatusWithTransient {
|
||||
let db_lock = DB.borrow_data().unwrap();
|
||||
let offline_state = db_lock.games.statuses.get(game_id).cloned();
|
||||
let online_state = db_lock.games.transient_statuses.get(game_id).cloned();
|
||||
drop(db_lock);
|
||||
|
||||
if online_state.is_some() {
|
||||
return (None, online_state);
|
||||
}
|
||||
|
||||
if offline_state.is_some() {
|
||||
return (offline_state, None);
|
||||
}
|
||||
|
||||
return (None, None);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user