mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-07-24 00:42:59 +10:00
chore(download manager): Renamed most instances of "game" outside of actual game downloads
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
+23
-23
@@ -6,18 +6,18 @@ use tauri::{AppHandle, Manager};
|
||||
use urlencoding::encode;
|
||||
|
||||
use crate::db::DatabaseImpls;
|
||||
use crate::db::GameVersion;
|
||||
use crate::db::GameStatus;
|
||||
use crate::download_manager::download_manager::{DownloadManagerStatus, GameDownloadStatus};
|
||||
use crate::db::ApplicationVersion;
|
||||
use crate::db::ApplicationStatus;
|
||||
use crate::download_manager::download_manager::{DownloadManagerStatus, DownloadStatus};
|
||||
use crate::process::process_manager::Platform;
|
||||
use crate::remote::RemoteAccessError;
|
||||
use crate::state::{GameStatusManager, GameStatusWithTransient};
|
||||
use crate::state::{DownloadStatusManager, ApplicationStatusWithTransient};
|
||||
use crate::{auth::generate_authorization_header, AppState, DB};
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
pub struct FetchGameStruct {
|
||||
game: Game,
|
||||
status: GameStatusWithTransient,
|
||||
status: ApplicationStatusWithTransient,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
@@ -37,13 +37,13 @@ pub struct Game {
|
||||
#[derive(serde::Serialize, Clone)]
|
||||
pub struct GameUpdateEvent {
|
||||
pub game_id: String,
|
||||
pub status: GameStatusWithTransient,
|
||||
pub status: ApplicationStatusWithTransient,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
pub struct QueueUpdateEventQueueData {
|
||||
pub id: String,
|
||||
pub status: GameDownloadStatus,
|
||||
pub status: DownloadStatus,
|
||||
pub progress: f64,
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ fn fetch_library_logic(app: AppHandle) -> Result<Vec<Game>, RemoteAccessError> {
|
||||
|
||||
for game in games.iter() {
|
||||
handle.games.insert(game.id.clone(), game.clone());
|
||||
if !db_handle.games.statuses.contains_key(&game.id) {
|
||||
if !db_handle.applications.statuses.contains_key(&game.id) {
|
||||
db_handle
|
||||
.games
|
||||
.applications
|
||||
.statuses
|
||||
.insert(game.id.clone(), GameStatus::Remote {});
|
||||
.insert(game.id.clone(), ApplicationStatus::Remote {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ fn fetch_game_logic(
|
||||
|
||||
let game = state_handle.games.get(&id);
|
||||
if let Some(game) = game {
|
||||
let status = GameStatusManager::fetch_state(&id);
|
||||
let status = DownloadStatusManager::fetch_state(&id);
|
||||
|
||||
let data = FetchGameStruct {
|
||||
game: game.clone(),
|
||||
@@ -161,13 +161,13 @@ fn fetch_game_logic(
|
||||
let mut db_handle = DB.borrow_data_mut().unwrap();
|
||||
|
||||
db_handle
|
||||
.games
|
||||
.applications
|
||||
.statuses
|
||||
.entry(id.clone())
|
||||
.or_insert(GameStatus::Remote {});
|
||||
.or_insert(ApplicationStatus::Remote {});
|
||||
drop(db_handle);
|
||||
|
||||
let status = GameStatusManager::fetch_state(&id);
|
||||
let status = DownloadStatusManager::fetch_state(&id);
|
||||
|
||||
let data = FetchGameStruct {
|
||||
game: game.clone(),
|
||||
@@ -189,8 +189,8 @@ pub fn fetch_game(id: String, app: tauri::AppHandle) -> Result<FetchGameStruct,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn fetch_game_status(id: String) -> Result<GameStatusWithTransient, String> {
|
||||
let status = GameStatusManager::fetch_state(&id);
|
||||
pub fn fetch_game_status(id: String) -> Result<ApplicationStatusWithTransient, String> {
|
||||
let status = DownloadStatusManager::fetch_state(&id);
|
||||
|
||||
Ok(status)
|
||||
}
|
||||
@@ -245,13 +245,13 @@ pub fn uninstall_game(
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<(), String> {
|
||||
let state_lock = state.lock().unwrap();
|
||||
state_lock.download_manager.uninstall_game(game_id);
|
||||
state_lock.download_manager.uninstall_application(game_id);
|
||||
drop(state_lock);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn push_game_update(app_handle: &AppHandle, id: String, status: GameStatusWithTransient) {
|
||||
pub fn push_application_update(app_handle: &AppHandle, id: String, status: ApplicationStatusWithTransient) {
|
||||
app_handle
|
||||
.emit(
|
||||
&format!("update_game/{}", id),
|
||||
@@ -288,11 +288,11 @@ pub fn on_game_complete(
|
||||
.header("Authorization", header)
|
||||
.send()?;
|
||||
|
||||
let data = response.json::<GameVersion>()?;
|
||||
let data = response.json::<ApplicationVersion>()?;
|
||||
|
||||
let mut handle = DB.borrow_data_mut().unwrap();
|
||||
handle
|
||||
.games
|
||||
.applications
|
||||
.versions
|
||||
.entry(game_id.clone())
|
||||
.or_default()
|
||||
@@ -301,12 +301,12 @@ pub fn on_game_complete(
|
||||
DB.save().unwrap();
|
||||
|
||||
let status = if data.setup_command.is_empty() {
|
||||
GameStatus::Installed {
|
||||
ApplicationStatus::Installed {
|
||||
version_name,
|
||||
install_dir,
|
||||
}
|
||||
} else {
|
||||
GameStatus::SetupRequired {
|
||||
ApplicationStatus::SetupRequired {
|
||||
version_name,
|
||||
install_dir,
|
||||
}
|
||||
@@ -314,7 +314,7 @@ pub fn on_game_complete(
|
||||
|
||||
let mut db_handle = DB.borrow_data_mut().unwrap();
|
||||
db_handle
|
||||
.games
|
||||
.applications
|
||||
.statuses
|
||||
.insert(game_id.clone(), status.clone());
|
||||
drop(db_handle);
|
||||
|
||||
Reference in New Issue
Block a user