From f5bd12b43aa0d37f3ad9e9863b10288c44a51f27 Mon Sep 17 00:00:00 2001 From: quexeky <116044207+quexeky@users.noreply.github.com> Date: Sat, 25 Jan 2025 18:49:54 +1100 Subject: [PATCH] Merge develop into main (#25) * chore(process manager): refactor for generic way to implement cross platform launchers * feat(game): game uninstalling & partial compat * chore(metadata): update metadata * feat(errors): better download manager errors + modal * feat(process): better process management, including running state * feat(downloads): lockless tracking of downloaded chunks * fix(sign on): add message about nonce expiration * feat(download ui): add speed and time remaining information closes #7 Co-authored-by: AdenMGB <140392385+AdenMGB@users.noreply.github.com> * chore: Ran cargo clippy Signed-off-by: quexeky * fix(auth initiate): add better error message * feat(auth): offer manual signin * feat(install modal): add note about more install dirs * fix(install flow): clear stale data before requesting new * Delete pages/library.vue * Add files via upload * adds nvm rc! * feat(install modal): add note about more install dirs * fix(install flow): clear stale data before requesting new * Delete pages/library.vue * Add files via upload * fix(library page): fix install button * fix(process): fix poorly designed parsing for executables with spaces * fix(scrollbars): fix ugly scrollbars on edge webview * feat(Compat): Implemented spawning with umu (using umu-wrapper-lib) Signed-off-by: quexeky * feat(process manager): Game kill tauri command Signed-off-by: quexeky * fix(deep links): Re-enabled deep links Signed-off-by: quexeky * feat(process): shared child with stop command * squash(autostart): added adenmgb's autostart feature Squashed commit of the following: commit 085cd9481dee748ee84c1a8f9dcd8ef0b01105ab Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 16:29:41 2024 +1030 Update lib.rs for the DB sync of autostart commit 86f2fb19bde3933ec6b5cd82701de0d306121659 Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 16:29:13 2024 +1030 Update db.rs to accomidate the settings sync commit ece11e7581c9aef55588b2e829379b1224021a45 Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 16:27:48 2024 +1030 Update autostart.rs to include DB commit 7ea8a24fdc2ff98379694ce8e347a40fcfd5fea3 Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 15:17:38 2024 +1030 Add files via upload commit af2f232d94fa449d9e20df737ce81ebded87fd50 Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 15:17:09 2024 +1030 Delete src-tauri/Cargo.toml commit 5d27b65612457de6eb30835d5423b9d96fd5a596 Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 15:15:42 2024 +1030 Add files via upload commit 2eea7b97a876e23cc0d6daec37f1b75af9bf3ae2 Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 15:15:31 2024 +1030 Delete src-tauri/src/lib.rs commit 9a635a10d1340f86c74812113284b115b34b9bbe Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 15:14:49 2024 +1030 Add files via upload commit 2fb049531a082fbdd217aba694819b7a3f954a55 Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 15:13:37 2024 +1030 Add files via upload commit ea1be4d7505a9ab16bda338491c0ec313d0bc586 Author: Aden Lindsay <140392385+AdenMGB@users.noreply.github.com> Date: Mon Dec 30 15:13:20 2024 +1030 Delete pages/settings/index.vue * fix(download manager): fix incorrect error assumptions & update types * feat(account settings): Add signout functionality (#16) * Create account.vue with logout button * Update auth.rs to add signout command * Update lib.rs to pass sign_out command to frontend * feat(settings): add debug page * Create debug.rs * Update settings.vue to add tab for debug * Update main.scss to add light theme * Update interface.vue to add light mode * Create debug.vue * Update debug.vue too add open log button * Update lib.rs * Update debug.rs * Update debug.rs * Update lib.rs * Update lib.rs * Update debug.rs * Update debug.vue * fix(debug): refactor and cleanup * revert(theme): revert light theming --------- Co-authored-by: DecDuck * feat(library ui): add installed ui in the library menu * chore(tool manager): Progress on adding tools Going to try changing around the download manager to take a generic trait rather than specifically for game downloads Signed-off-by: quexeky * refactor(download manager): Moved download manager to separate directory Signed-off-by: quexeky * refactor(download manager): Added Downloadable trait and replaced references to GameDownloadAgent Signed-off-by: quexeky * chore(download manager): Renamed most instances of "game" outside of actual game downloads Signed-off-by: quexeky * refactor(download manager): Renamed GameDonwloadError to ApplicationDownloadError and moved Signed-off-by: quexeky * chore(download manager): Some easy cleanup of the download manager Signed-off-by: quexeky * chore(download manager): Ensure that Downloadable is also send and sync Signed-off-by: quexeky * refactor(download manager): Moved manifest and stored_manifest to download_manager Signed-off-by: quexeky * Revert "refactor(download manager): Moved manifest and stored_manifest to download_manager" This reverts commit 8db239334688912f2be30023f4220c3e149df7d6. * chore(tool manager): Added ToolDownloadAgent Signed-off-by: quexeky * chore(download manager): Added manage_queue_signal Signed-off-by: quexeky * chore(download manager): Added manage_go_signal command Signed-off-by: quexeky * refactor(download manager): Removed all references to anything outside of the DownloadManager Signed-off-by: quexeky * refactor(download manager): Fully separate & generic download manager Signed-off-by: quexeky * refactor(download manager): Removed Arc requirement for DownloadableMetadata Signed-off-by: quexeky * feat(download manager): Added generic download manager Signed-off-by: quexeky * fix(game launcher): Renamed game_id to id Signed-off-by: quexeky * fix(uninstalling): Re-enabled uninstalling apps Signed-off-by: quexeky * refactor(downloads): Moved all files relevant to game downloads to their own directory Signed-off-by: quexeky * fix(kill game): Re-enabled killing games Signed-off-by: quexeky * feat(recovery): Added database recovery Signed-off-by: quexeky * feat(database): Added database corruption dialog Signed-off-by: quexeky * chore(README): Updated README.md Signed-off-by: quexeky * perf(game downloads): Moved some variable declarations outside of the spawned download thread Signed-off-by: quexeky * fix(game downloads): Accidentally was attempting to lock onto something that was already in scope Signed-off-by: quexeky * fix(db): Added Settings component Signed-off-by: quexeky * refactor: Ran cargo clippy & fmt Signed-off-by: quexeky * chore: More cleanup after cargo clippy Also added some type efficiency improvements (using references where possible and added SliceDeque crate) Signed-off-by: quexeky * feat(settings): Added max_download_threads setting and separated settings from db Signed-off-by: quexeky * chore: Moved generateGameMeta.ts to composables, using PathBuf instead of String for install_dirs Signed-off-by: quexeky * chore: General cleanup - Changed some info!() statements to debug!() and warn!() - Removed most Turbofish syntax cases - Removed InvalidCodeError and replaced it with InvalidResponse Signed-off-by: quexeky * chore: Removed tests/ Signed-off-by: quexeky * chore: Removed tools/ Signed-off-by: quexeky * chore: More refining info!() statements Signed-off-by: quexeky * feat(download manager): Added UI to change download threads Co-authored-by: AdenMGB <140392385+AdenMGB@users.noreply.github.com> Signed-off-by: quexeky * fix(metadata): update routes for new server * fix(handle invalid database): use set_file_name instead of pushing to strings * refactor(compat): remove unnecessary compat code (#20) * Delete pages/settings/compatibility.vue * Update settings.vue * Update debug.vue * Update lib.rs * Update compat.rs * feat(debug): use shift or DEBUG RUST_LOG to show Debug Info * Update settings.vue to have a conditional debug page * Update debug.rs to add RUST_LOG status fetching * Implement better error system and segregate errors and commands (#23) * chore: Progress on amend_settings command Signed-off-by: quexeky * chore(errors): Progress on better error handling with segragation of files * chore: Progress on amend_settings command Signed-off-by: quexeky * chore(commands): Separated commands under each subdirectory into respective commands.rs files Signed-off-by: quexeky * chore(errors): Almost all errors and commands have been segregated * chore(errors): Added drop server error Signed-off-by: quexeky * feat(core): Update to using nightly compiler Signed-off-by: quexeky * chore(errors): More progress on error handling Signed-off-by: quexeky * chore(errors): Implementing Try and FromResidual for UserValue Signed-off-by: quexeky * refactor(errors): Segregated errors and commands from code, and made commands return UserValue struct Signed-off-by: quexeky * fix(errors): Added missing files * chore(errors): Convert match statement to map_err * feat(settings): Implemented settings editing from UI * feat(errors): Clarified return values from retry_connect command * chore(errors): Moved autostart commands to autostart.rs * chore(process manager): Converted launch_process function for games to use game_id --------- Signed-off-by: quexeky * fix(settings): Broken command invoke logic in settings/downloads.vue * feat(logging): Added line numbers to file logging and highlighting to console * chore(progress): Added rolling_progress_updates.rs Signed-off-by: quexeky * chore(exit): Progress on cleanup and exit * chore(downloads): Progress on terminator * chore: Progress on rolling progress window * feat(progress): Added rolling progress window Still needs tweaks on specific timings, as well as cleanup * refactor(remote): Created separate function to generate requests * fix(install ui): stop loading on error * fix: fix other metadata endpoints * feat(errors): Using SerializeDisplay for better error management with Result * chore: Update .gitlab-ci.yml * refactor(logging): Using more appropriate logging statements Still probably needs some work, but that's enough for now * chore(logging): Imported appropriate logging macros * Revert "chore: Update .gitlab-ci.yml" This reverts commit fc6bab93811abc03f5f338a5ab4df955c91fde8f. * feat(settings): Allow settings to update UI using fetch_settings command * style(logging): Ensured that all logs start with lowercase capital and have no trailing punctuation * fix(download manager): don't crash download manager if multiple errors come in * feat(downloads): re-enable checksums * fix(logs): add file & line to console logs * fix(ui): modal stack doesn't cover whole app * feat(database): Ensure that any database issues are resolved by standalone functions Functions are as follows: - save_db() - borrow_db_checked() - borrow_db_mut_checked() * chore: Ran cargo clippy & cargo fmt * fix: assorted fixes * fix(download agent): fixed completed indexes * fix: Adding usize to completed_contexts_lock instead of &usize * fix(game downloads): Added error handling for chunk request errors * chore: Apply stashed changes * feat(games): Added multi-argument game launch and setup support * fix: Games not launching due to string semantics * build: Version bump & appimage build * chore: Update .gitlab-ci.yml * Update .gitlab-ci.yml * Update .gitlab-ci.yml with artifacts * feat(settings): Made save button include user feedback & only allow numeric characters * fix(library): Added "LIbrary Failed to Update" content to recover from library load fail * fix(logging): Restored RUST_LOG env functionality * Update changelog.md --------- Signed-off-by: quexeky Signed-off-by: DecDuck Co-authored-by: DecDuck Co-authored-by: AdenMGB <140392385+AdenMGB@users.noreply.github.com> Co-authored-by: seethruhead --- .gitlab-ci.yml | 3 +- .nvmrc | 1 + README.md | 15 +- app.vue | 16 +- assets/main.scss | 22 + changelog.md | 287 ++++++++++ components/GameStatusButton.vue | 87 ++- components/InitiateAuthModule.vue | 47 ++ components/PageWidget.vue | 7 + composables/downloads.ts | 34 ++ composables/game.ts | 26 +- composables/generateGameMeta.ts | 9 + composables/queue.ts | 13 - composables/state-navigation.ts | 19 +- layouts/default.vue | 2 +- layouts/mini.vue | 2 +- package.json | 2 +- pages/account.vue | 72 +++ pages/auth/failed.vue | 2 +- pages/index.vue | 3 + pages/library.vue | 71 ++- pages/library/[id]/index.vue | 535 ++++++++---------- pages/library/index.vue | 8 +- pages/queue.vue | 135 ++++- pages/settings.vue | 91 ++- pages/settings/debug.vue | 136 +++++ pages/settings/downloads.vue | 97 +++- pages/settings/index.vue | 61 +- pages/settings/interface.vue | 6 +- plugins/global-error-handler.ts | 2 +- src-tauri/Cargo.lock | 230 +++++++- src-tauri/Cargo.toml | 25 +- src-tauri/capabilities/default.json | 3 +- src-tauri/rust-toolchain.toml | 2 + src-tauri/src/autostart.rs | 76 +++ src-tauri/src/cleanup.rs | 21 +- src-tauri/src/commands.rs | 11 + src-tauri/src/database/commands.rs | 92 +++ src-tauri/src/database/db.rs | 256 +++++++++ src-tauri/src/database/debug.rs | 21 + src-tauri/src/database/mod.rs | 4 + src-tauri/src/database/settings.rs | 24 + src-tauri/src/db.rs | 204 ------- src-tauri/src/download_manager/commands.rs | 31 + .../download_manager.rs | 138 ++--- .../download_manager_builder.rs | 362 ++++++++++++ .../download_thread_control_flag.rs | 0 .../src/download_manager/downloadable.rs | 23 + .../download_manager/downloadable_metadata.rs | 26 + .../src/download_manager/internal_error.rs | 27 + src-tauri/src/download_manager/mod.rs | 10 + .../src/download_manager/progress_object.rs | 155 +++++ src-tauri/src/download_manager/queue.rs | 80 +++ .../rolling_progress_updates.rs | 33 ++ src-tauri/src/downloads/download_agent.rs | 335 ----------- src-tauri/src/downloads/download_commands.rs | 62 -- .../src/downloads/download_manager_builder.rs | 417 -------------- src-tauri/src/downloads/mod.rs | 10 - src-tauri/src/downloads/progress_object.rs | 111 ---- src-tauri/src/downloads/queue.rs | 73 --- .../src/error/application_download_error.rs | 32 ++ src-tauri/src/error/drop_server_error.rs | 10 + src-tauri/src/error/library_error.rs | 19 + src-tauri/src/error/mod.rs | 6 + src-tauri/src/error/process_error.rs | 31 + src-tauri/src/error/remote_access_error.rs | 69 +++ src-tauri/src/error/setup_error.rs | 14 + src-tauri/src/games/commands.rs | 53 ++ src-tauri/src/games/downloads/commands.rs | 32 ++ .../src/games/downloads/download_agent.rs | 407 +++++++++++++ .../{ => games}/downloads/download_logic.rs | 88 ++- .../src/{ => games}/downloads/manifest.rs | 0 src-tauri/src/games/downloads/mod.rs | 5 + .../{ => games}/downloads/stored_manifest.rs | 17 +- src-tauri/src/games/library.rs | 353 ++++++++++++ src-tauri/src/games/mod.rs | 4 + src-tauri/src/games/state.rs | 29 + src-tauri/src/lib.rs | 245 +++++--- src-tauri/src/library.rs | 302 ---------- src-tauri/src/process/commands.rs | 40 ++ src-tauri/src/process/compat.rs | 13 + src-tauri/src/process/mod.rs | 3 +- src-tauri/src/process/process_commands.rs | 16 - src-tauri/src/process/process_manager.rs | 377 +++++++++--- src-tauri/src/remote.rs | 132 ----- src-tauri/src/{ => remote}/auth.rs | 128 ++--- src-tauri/src/remote/commands.rs | 78 +++ src-tauri/src/remote/mod.rs | 4 + src-tauri/src/remote/remote.rs | 48 ++ src-tauri/src/remote/requests.rs | 23 + src-tauri/src/state.rs | 31 - src-tauri/src/tests/mod.rs | 1 - src-tauri/src/tests/progress_tests.rs | 29 - src-tauri/tauri.conf.json | 7 +- types.ts | 19 + yarn.lock | 12 +- 96 files changed, 4812 insertions(+), 2538 deletions(-) create mode 100644 .nvmrc create mode 100644 components/PageWidget.vue create mode 100644 composables/downloads.ts create mode 100644 composables/generateGameMeta.ts delete mode 100644 composables/queue.ts create mode 100644 pages/account.vue create mode 100644 pages/settings/debug.vue create mode 100644 src-tauri/rust-toolchain.toml create mode 100644 src-tauri/src/autostart.rs create mode 100644 src-tauri/src/commands.rs create mode 100644 src-tauri/src/database/commands.rs create mode 100644 src-tauri/src/database/db.rs create mode 100644 src-tauri/src/database/debug.rs create mode 100644 src-tauri/src/database/mod.rs create mode 100644 src-tauri/src/database/settings.rs delete mode 100644 src-tauri/src/db.rs create mode 100644 src-tauri/src/download_manager/commands.rs rename src-tauri/src/{downloads => download_manager}/download_manager.rs (54%) create mode 100644 src-tauri/src/download_manager/download_manager_builder.rs rename src-tauri/src/{downloads => download_manager}/download_thread_control_flag.rs (100%) create mode 100644 src-tauri/src/download_manager/downloadable.rs create mode 100644 src-tauri/src/download_manager/downloadable_metadata.rs create mode 100644 src-tauri/src/download_manager/internal_error.rs create mode 100644 src-tauri/src/download_manager/mod.rs create mode 100644 src-tauri/src/download_manager/progress_object.rs create mode 100644 src-tauri/src/download_manager/queue.rs create mode 100644 src-tauri/src/download_manager/rolling_progress_updates.rs delete mode 100644 src-tauri/src/downloads/download_agent.rs delete mode 100644 src-tauri/src/downloads/download_commands.rs delete mode 100644 src-tauri/src/downloads/download_manager_builder.rs delete mode 100644 src-tauri/src/downloads/mod.rs delete mode 100644 src-tauri/src/downloads/progress_object.rs delete mode 100644 src-tauri/src/downloads/queue.rs create mode 100644 src-tauri/src/error/application_download_error.rs create mode 100644 src-tauri/src/error/drop_server_error.rs create mode 100644 src-tauri/src/error/library_error.rs create mode 100644 src-tauri/src/error/mod.rs create mode 100644 src-tauri/src/error/process_error.rs create mode 100644 src-tauri/src/error/remote_access_error.rs create mode 100644 src-tauri/src/error/setup_error.rs create mode 100644 src-tauri/src/games/commands.rs create mode 100644 src-tauri/src/games/downloads/commands.rs create mode 100644 src-tauri/src/games/downloads/download_agent.rs rename src-tauri/src/{ => games}/downloads/download_logic.rs (64%) rename src-tauri/src/{ => games}/downloads/manifest.rs (100%) create mode 100644 src-tauri/src/games/downloads/mod.rs rename src-tauri/src/{ => games}/downloads/stored_manifest.rs (85%) create mode 100644 src-tauri/src/games/library.rs create mode 100644 src-tauri/src/games/mod.rs create mode 100644 src-tauri/src/games/state.rs delete mode 100644 src-tauri/src/library.rs create mode 100644 src-tauri/src/process/commands.rs create mode 100644 src-tauri/src/process/compat.rs delete mode 100644 src-tauri/src/process/process_commands.rs delete mode 100644 src-tauri/src/remote.rs rename src-tauri/src/{ => remote}/auth.rs (62%) create mode 100644 src-tauri/src/remote/commands.rs create mode 100644 src-tauri/src/remote/mod.rs create mode 100644 src-tauri/src/remote/remote.rs create mode 100644 src-tauri/src/remote/requests.rs delete mode 100644 src-tauri/src/state.rs delete mode 100644 src-tauri/src/tests/mod.rs delete mode 100644 src-tauri/src/tests/progress_tests.rs diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b9088a8..0fc3abe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,9 +13,10 @@ build-linux: - yarnpkg tauri build - cp src-tauri/target/release/bundle/deb/*.deb . - cp src-tauri/target/release/bundle/rpm/*.rpm . + - cp src-tauri/target/release/bundle/appimage/*.AppImage . artifacts: paths: - - "*.{deb,rpm}" + - "*.{deb,rpm,AppImage}" build-windows: stage: build diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..4099407 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +23 diff --git a/README.md b/README.md index b0df333..903f4ca 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,19 @@ Drop app is the companion app for [Drop](https://github.com/Drop-OSS/drop). It uses a Tauri base with Nuxt 3 + TailwindCSS on top of it, so we can re-use components from the web UI. +## Running +Before setting up the drop app, be sure that you have a server set up. +The instructions for this can be found on the [Drop Wiki](https://wiki.droposs.org/guides/quickstart.html) + +## Current features +Currently supported are the following features: +- Signin (with custom server) +- Database registering & recovery +- Dynamic library fetching from server +- Installing & uninstalling games +- Download progress monitoring +- Launching / playing games + ## Development Install dependencies with `yarn` @@ -10,7 +23,7 @@ Run the app in development with `yarn tauri dev`. NVIDIA users on Linux, use she To manually specify the logging level, add the environment variable `RUST_LOG=[debug, info, warn, error]` to `yarn tauri dev`: -e.g. `RUST_LOG=debug yarn taudi dev` +e.g. `RUST_LOG=debug yarn tauri dev` ## Contributing Check the original [Drop repo](https://github.com/Drop-OSS/drop/blob/main/CONTRIBUTING.md) for contributing guidelines. \ No newline at end of file diff --git a/app.vue b/app.vue index b921045..b9011c6 100644 --- a/app.vue +++ b/app.vue @@ -1,12 +1,12 @@ diff --git a/components/InitiateAuthModule.vue b/components/InitiateAuthModule.vue index 5f7158c..1f9be6c 100644 --- a/components/InitiateAuthModule.vue +++ b/components/InitiateAuthModule.vue @@ -42,6 +42,31 @@ +
+

Having trouble?

+

+ You can manually enter the token from your web browser. +

+
+ + + Submit + +
+
+
@@ -101,6 +126,10 @@ import { invoke } from "@tauri-apps/api/core"; const loading = ref(false); const error = ref(); +const offerManual = ref(false); +const manualToken = ref(""); +const manualLoading = ref(false); + async function auth() { await invoke("auth_initiate"); } @@ -111,5 +140,23 @@ function authWrapper_wrapper() { loading.value = false; error.value = e; }); + setTimeout(() => { + offerManual.value = true; + }, 10000); +} + +async function continueManual() { + await invoke("manual_recieve_handshake", { token: manualToken.value }); +} + +function continueManual_wrapper() { + loading.value = true; + continueManual() + .catch((e) => { + error.value = e; + }) + .finally(() => { + loading.value = false; + }); } diff --git a/components/PageWidget.vue b/components/PageWidget.vue new file mode 100644 index 0000000..ad9428b --- /dev/null +++ b/components/PageWidget.vue @@ -0,0 +1,7 @@ + diff --git a/composables/downloads.ts b/composables/downloads.ts new file mode 100644 index 0000000..d75c46f --- /dev/null +++ b/composables/downloads.ts @@ -0,0 +1,34 @@ +import { listen } from "@tauri-apps/api/event"; +import type { DownloadableMetadata } from "~/types"; + +export type QueueState = { + queue: Array<{ + meta: DownloadableMetadata; + status: string; + progress: number | null; + current: number; + max: number; + }>; + status: string; +}; + +export type StatsState = { + speed: number; // Bytes per second + time: number; // Seconds, +}; + +export const useQueueState = () => + useState("queue", () => ({ queue: [], status: "Unknown" })); + +export const useStatsState = () => + useState("stats", () => ({ speed: 0, time: 0 })); + +listen("update_queue", (event) => { + const queue = useQueueState(); + queue.value = event.payload as QueueState; +}); + +listen("update_stats", (event) => { + const stats = useStatsState(); + stats.value = event.payload as StatsState; +}); diff --git a/composables/game.ts b/composables/game.ts index 7f28435..0335a7a 100644 --- a/composables/game.ts +++ b/composables/game.ts @@ -12,7 +12,8 @@ export type SerializedGameStatus = [ OptionGameStatus | null ]; -const parseStatus = (status: SerializedGameStatus): GameStatus => { +export const parseStatus = (status: SerializedGameStatus): GameStatus => { + console.log(status); if (status[0]) { return { type: status[0].type, @@ -28,28 +29,29 @@ const parseStatus = (status: SerializedGameStatus): GameStatus => { } }; -export const useGame = async (id: string) => { - if (!gameRegistry[id]) { +export const useGame = async (gameId: string) => { + if (!gameRegistry[gameId]) { const data: { game: Game; status: SerializedGameStatus } = await invoke( "fetch_game", { - id, + gameId, } ); - gameRegistry[id] = data.game; - if (!gameStatusRegistry[id]) { - gameStatusRegistry[id] = ref(parseStatus(data.status)); + gameRegistry[gameId] = data.game; + if (!gameStatusRegistry[gameId]) { + gameStatusRegistry[gameId] = ref(parseStatus(data.status)); - listen(`update_game/${id}`, (event) => { + listen(`update_game/${gameId}`, (event) => { const payload: { status: SerializedGameStatus; } = event.payload as any; - gameStatusRegistry[id].value = parseStatus(payload.status); + console.log(payload.status); + gameStatusRegistry[gameId].value = parseStatus(payload.status); }); } } - const game = gameRegistry[id]; - const status = gameStatusRegistry[id]; + const game = gameRegistry[gameId]; + const status = gameStatusRegistry[gameId]; return { game, status }; -}; +}; \ No newline at end of file diff --git a/composables/generateGameMeta.ts b/composables/generateGameMeta.ts new file mode 100644 index 0000000..fdfc4b7 --- /dev/null +++ b/composables/generateGameMeta.ts @@ -0,0 +1,9 @@ +import { type DownloadableMetadata, DownloadableType } from '~/types' + +export default function generateGameMeta(gameId: string, version: string): DownloadableMetadata { + return { + id: gameId, + version, + downloadType: DownloadableType.Game + } +} \ No newline at end of file diff --git a/composables/queue.ts b/composables/queue.ts deleted file mode 100644 index 0487260..0000000 --- a/composables/queue.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { listen } from "@tauri-apps/api/event"; - -export type QueueState = { - queue: Array<{ id: string; status: string, progress: number | null }>; -}; - -export const useQueueState = () => - useState("queue", () => ({ queue: [] })); - -listen("update_queue", (event) => { - const queue = useQueueState(); - queue.value = event.payload as QueueState; -}); diff --git a/composables/state-navigation.ts b/composables/state-navigation.ts index 790d258..46d9e2b 100644 --- a/composables/state-navigation.ts +++ b/composables/state-navigation.ts @@ -1,4 +1,5 @@ import { listen } from "@tauri-apps/api/event"; +import { data } from "autoprefixer"; import { AppStatus, type AppState } from "~/types"; export function setupHooks() { @@ -18,6 +19,20 @@ export function setupHooks() { router.push("/store"); }); + listen("download_error", (event) => { + createModal( + ModalType.Notification, + { + title: "Drop encountered an error while downloading", + description: `Drop encountered an error while downloading your game: "${( + event.payload as unknown as string + ).toString()}"`, + buttonText: "Close" + }, + (e, c) => c() + ); + }); + /* document.addEventListener("contextmenu", (event) => { @@ -33,9 +48,7 @@ export function initialNavigation(state: Ref) { switch (state.value.status) { case AppStatus.NotConfigured: - router.push({ path: "/setup" }).then(() => { - console.log("Pushed Setup"); - }); + router.push({ path: "/setup" }); break; case AppStatus.SignedOut: router.push("/auth"); diff --git a/layouts/default.vue b/layouts/default.vue index 89dd49b..025a7cf 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,7 +1,7 @@