diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2022-09-20 21:10:34 +0200 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2022-09-20 21:10:34 +0200 |
commit | cc82d961fc0d4d80e0f44857fe2b462c5108fa9a (patch) | |
tree | dcc4bad5d2995946861074f2416dedb777a4ee86 /src-ui/src | |
parent | 6553d959f0a0504a1f13c116f11bfe0116d8ff63 (diff) | |
download | FlightCore-cc82d961fc0d4d80e0f44857fe2b462c5108fa9a.tar.gz FlightCore-cc82d961fc0d4d80e0f44857fe2b462c5108fa9a.zip |
Make button to select NS RC persistent
Uses a tauri plugin for persistent store behind the scenes to persist
values over restarts of the application.
Diffstat (limited to 'src-ui/src')
-rw-r--r-- | src-ui/src/main.ts | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts index f7aa6ec6..1da081e9 100644 --- a/src-ui/src/main.ts +++ b/src-ui/src/main.ts @@ -2,6 +2,9 @@ import { invoke } from "@tauri-apps/api"; import { listen, Event as TauriEvent } from "@tauri-apps/api/event"; import { open } from '@tauri-apps/api/dialog'; import { appDir } from '@tauri-apps/api/path'; +import { Store } from 'tauri-plugin-store-api'; + +const store = new Store('flight-core-settings.json'); const $ = document.querySelector.bind(document); const button_install_string = "Install Northstar"; @@ -100,7 +103,7 @@ document.addEventListener("DOMContentLoaded", async function () { let northstarVersionHolderEl = $("northstar-version-holder") as HTMLElement; let useReleaseCandidateCheckboxEl = document.getElementById("use-release-candidate-checkbox") as HTMLInputElement; - useReleaseCandidateCheckboxEl.addEventListener('change', function () { + useReleaseCandidateCheckboxEl.addEventListener('change', async function () { // Switch between main release and release candidates if (this.checked) { globalState.northstar_package_name = "NorthstarReleaseCandidate" @@ -109,6 +112,9 @@ document.addEventListener("DOMContentLoaded", async function () { } // Update the button get_northstar_version_number_and_set_button_accordingly(omniButtonEl); + + // Save change in persistent store + await store.set('northstar-package-name', { value: globalState.northstar_package_name }); }); // listen backend-ping event (from Tauri Rust App) @@ -255,6 +261,18 @@ document.addEventListener("DOMContentLoaded", async function () { let host_os_string = await invoke("get_host_os_caller") as string; versionNumberHolderEl.textContent = `${version_number_string} (${host_os_string})${outdated_string}`; + // Get preferred Northstar version from persistent store + const persistent_northstar_package_name = ((await store.get('northstar-package-name')) as any).value; + if (persistent_northstar_package_name) { + console.log(persistent_northstar_package_name) + globalState.northstar_package_name = persistent_northstar_package_name as string; + // Update checkbox if it's a ReleaseCandidate + // In the future this might be a dropdown menu instead + if (globalState.northstar_package_name === "NorthstarReleaseCandidate") { + useReleaseCandidateCheckboxEl.checked = true; + } + } + // Get install location await invoke("find_game_install_location_caller", { gamePath: globalState.gamepath }) .then((game_install) => { |