mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-10 04:22:13 +10:00
fix: error with game options for remote games
This commit is contained in:
@ -46,9 +46,21 @@ export const useGame = async (gameId: string) => {
|
||||
listen(`update_game/${gameId}`, (event) => {
|
||||
const payload: {
|
||||
status: SerializedGameStatus;
|
||||
version?: GameVersion;
|
||||
} = event.payload as any;
|
||||
console.log(payload.status);
|
||||
gameStatusRegistry[gameId].value = parseStatus(payload.status);
|
||||
|
||||
/**
|
||||
* I am not super happy about this.
|
||||
*
|
||||
* This will mean that we will still have a version assigned if we have a game installed then uninstall it.
|
||||
* It is necessary because a flag to check if we should overwrite seems excessive, and this function gets called
|
||||
* on transient state updates.
|
||||
*/
|
||||
if (payload.version) {
|
||||
gameRegistry[gameId].version = payload.version;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@
|
||||
</template>
|
||||
</ModalTemplate>
|
||||
|
||||
<GameOptionsModal v-model="configureModalOpen" :game-id="game.id" />
|
||||
<GameOptionsModal v-if="status.type === GameStatusEnum.Installed" v-model="configureModalOpen" :game-id="game.id" />
|
||||
|
||||
<Transition
|
||||
enter="transition ease-out duration-300"
|
||||
@ -464,6 +464,7 @@ import { BuildingStorefrontIcon } from "@heroicons/vue/24/outline";
|
||||
import { XCircleIcon } from "@heroicons/vue/24/solid";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { micromark } from "micromark";
|
||||
import { GameStatusEnum } from "~/types";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
@ -199,20 +199,6 @@ impl DatabaseImpls for DatabaseInterface {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_game_status<F: FnOnce(&mut RwLockWriteGuard<'_, Database>, &DownloadableMetadata)>(
|
||||
app_handle: &AppHandle,
|
||||
meta: DownloadableMetadata,
|
||||
setter: F,
|
||||
) {
|
||||
let mut db_handle = borrow_db_mut_checked();
|
||||
setter(&mut db_handle, &meta);
|
||||
drop(db_handle);
|
||||
save_db();
|
||||
|
||||
let status = GameStatusManager::fetch_state(&meta.id);
|
||||
|
||||
push_game_update(app_handle, &meta.id, status);
|
||||
}
|
||||
// TODO: Make the error relelvant rather than just assume that it's a Deserialize error
|
||||
fn handle_invalid_database(
|
||||
_e: RustbreakError,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::auth::generate_authorization_header;
|
||||
use crate::database::db::{
|
||||
borrow_db_checked, set_game_status, ApplicationTransientStatus, DatabaseImpls,
|
||||
borrow_db_checked, ApplicationTransientStatus, DatabaseImpls,
|
||||
GameDownloadStatus,
|
||||
};
|
||||
use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus};
|
||||
@ -99,6 +99,7 @@ impl GameDownloadAgent {
|
||||
push_game_update(
|
||||
app_handle,
|
||||
&self.metadata().id,
|
||||
None,
|
||||
(
|
||||
None,
|
||||
Some(ApplicationTransientStatus::Downloading {
|
||||
@ -375,9 +376,8 @@ impl Downloadable for GameDownloadAgent {
|
||||
|
||||
error!("error while managing download: {}", error);
|
||||
|
||||
set_game_status(app_handle, self.metadata(), |db_handle, meta| {
|
||||
db_handle.applications.transient_statuses.remove(meta);
|
||||
});
|
||||
let mut handle = DB.borrow_data_mut().unwrap();
|
||||
handle.applications.transient_statuses.remove(&self.metadata());
|
||||
}
|
||||
|
||||
fn on_complete(&self, app_handle: &tauri::AppHandle) {
|
||||
@ -399,6 +399,7 @@ impl Downloadable for GameDownloadAgent {
|
||||
GameUpdateEvent {
|
||||
game_id: meta.id.clone(),
|
||||
status: (Some(GameDownloadStatus::Remote {}), None),
|
||||
version: None,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -48,6 +48,7 @@ pub struct GameUpdateEvent {
|
||||
Option<GameDownloadStatus>,
|
||||
Option<ApplicationTransientStatus>,
|
||||
),
|
||||
pub version: Option<GameVersion>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
@ -291,6 +292,7 @@ pub fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle)
|
||||
push_game_update(
|
||||
app_handle,
|
||||
&meta.id,
|
||||
None,
|
||||
(None, Some(ApplicationTransientStatus::Uninstalling {})),
|
||||
);
|
||||
|
||||
@ -346,6 +348,7 @@ pub fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle)
|
||||
push_game_update(
|
||||
&app_handle,
|
||||
&meta.id,
|
||||
None,
|
||||
(Some(GameDownloadStatus::Remote {}), None),
|
||||
);
|
||||
}
|
||||
@ -385,7 +388,7 @@ pub fn on_game_complete(
|
||||
)?
|
||||
.send()?;
|
||||
|
||||
let data: GameVersion = response.json()?;
|
||||
let game_version: GameVersion = response.json()?;
|
||||
|
||||
let mut handle = borrow_db_mut_checked();
|
||||
handle
|
||||
@ -393,7 +396,7 @@ pub fn on_game_complete(
|
||||
.game_versions
|
||||
.entry(meta.id.clone())
|
||||
.or_default()
|
||||
.insert(meta.version.clone().unwrap(), data.clone());
|
||||
.insert(meta.version.clone().unwrap(), game_version.clone());
|
||||
handle
|
||||
.applications
|
||||
.installed_game_version
|
||||
@ -402,7 +405,7 @@ pub fn on_game_complete(
|
||||
drop(handle);
|
||||
save_db();
|
||||
|
||||
let status = if data.setup_command.is_empty() {
|
||||
let status = if game_version.setup_command.is_empty() {
|
||||
GameDownloadStatus::Installed {
|
||||
version_name: meta.version.clone().unwrap(),
|
||||
install_dir,
|
||||
@ -427,6 +430,7 @@ pub fn on_game_complete(
|
||||
GameUpdateEvent {
|
||||
game_id: meta.id.clone(),
|
||||
status: (Some(status), None),
|
||||
version: Some(game_version),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
@ -434,13 +438,14 @@ pub fn on_game_complete(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn push_game_update(app_handle: &AppHandle, game_id: &String, status: GameStatusWithTransient) {
|
||||
pub fn push_game_update(app_handle: &AppHandle, game_id: &String, version: Option<GameVersion>, status: GameStatusWithTransient) {
|
||||
app_handle
|
||||
.emit(
|
||||
&format!("update_game/{}", game_id),
|
||||
GameUpdateEvent {
|
||||
game_id: game_id.clone(),
|
||||
status,
|
||||
version,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
@ -464,7 +469,6 @@ pub fn update_game_configuration(
|
||||
.get(&game_id)
|
||||
.ok_or(LibraryError::MetaNotFound(game_id))?;
|
||||
|
||||
|
||||
let id = installed_version.id.clone();
|
||||
let version = installed_version.version.clone().unwrap();
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ impl ProcessManager<'_> {
|
||||
|
||||
let status = GameStatusManager::fetch_state(&game_id);
|
||||
|
||||
push_game_update(&self.app_handle, &game_id, status);
|
||||
push_game_update(&self.app_handle, &game_id, None, status);
|
||||
|
||||
// TODO better management
|
||||
}
|
||||
@ -296,6 +296,7 @@ impl ProcessManager<'_> {
|
||||
push_game_update(
|
||||
&self.app_handle,
|
||||
&meta.id,
|
||||
None,
|
||||
(None, Some(ApplicationTransientStatus::Running {})),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user