diff options
-rw-r--r-- | package-lock.json | 26 | ||||
-rw-r--r-- | package.json | 3 | ||||
-rw-r--r-- | src-tauri/Cargo.lock | 13 | ||||
-rw-r--r-- | src-tauri/Cargo.toml | 2 | ||||
-rw-r--r-- | src-tauri/src/main.rs | 2 | ||||
-rw-r--r-- | src-ui/src/main.ts | 20 |
6 files changed, 59 insertions, 7 deletions
diff --git a/package-lock.json b/package-lock.json index 8b31a082..80466586 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,8 @@ "": { "name": "flightcore", "dependencies": { - "@tauri-apps/api": "^1.1.0" + "@tauri-apps/api": "^1.1.0", + "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#dev" }, "devDependencies": { "@rollup/plugin-node-resolve": "^13.3.0", @@ -447,11 +448,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tauri-plugin-store-api": { + "version": "0.1.0", + "resolved": "git+ssh://git@github.com/tauri-apps/tauri-plugin-store.git#d8efb964bb1894bdf01407693ee896d0f9c557b3", + "license": "MIT", + "dependencies": { + "@tauri-apps/api": "1.1.0", + "tslib": "2.4.0" + } + }, "node_modules/tslib": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", - "dev": true + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, "node_modules/typescript": { "version": "4.8.3", @@ -717,11 +726,18 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "tauri-plugin-store-api": { + "version": "git+ssh://git@github.com/tauri-apps/tauri-plugin-store.git#d8efb964bb1894bdf01407693ee896d0f9c557b3", + "from": "tauri-plugin-store-api@https://github.com/tauri-apps/tauri-plugin-store#dev", + "requires": { + "@tauri-apps/api": "1.1.0", + "tslib": "2.4.0" + } + }, "tslib": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", - "dev": true + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, "typescript": { "version": "4.8.3", diff --git a/package.json b/package.json index 5430f4c6..c45d7222 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "ui-dev": "./node_modules/.bin/rollup --config --watch & npm run localhost" }, "dependencies": { - "@tauri-apps/api": "^1.1.0" + "@tauri-apps/api": "^1.1.0", + "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#dev" }, "devDependencies": { "@rollup/plugin-node-resolve": "^13.3.0", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 1ef32cb6..d78828eb 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -90,6 +90,7 @@ dependencies = [ "sysinfo", "tauri", "tauri-build", + "tauri-plugin-store", "tokio", "zip", ] @@ -3467,6 +3468,18 @@ dependencies = [ ] [[package]] +name = "tauri-plugin-store" +version = "0.0.0" +source = "git+https://github.com/tauri-apps/tauri-plugin-store?branch=dev#d8efb964bb1894bdf01407693ee896d0f9c557b3" +dependencies = [ + "log", + "serde", + "serde_json", + "tauri", + "thiserror", +] + +[[package]] name = "tauri-runtime" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1c077992..0dc2873e 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -36,6 +36,8 @@ regex = "1.6.0" sysinfo = "0.26.2" # HTTP requests reqwest = { version = "0.11", features = ["blocking"] } +# Persistent store for settings +tauri-plugin-store = { git = "https://github.com/tauri-apps/tauri-plugin-store", branch = "dev" } [features] # by default Tauri runs in production mode diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c6c51e2b..492c5935 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -16,6 +16,7 @@ use app::{ }; use tauri::{Manager, State}; use tokio::time::sleep; +use tauri_plugin_store::PluginBuilder; #[derive(Default)] struct Counter(Arc<Mutex<i32>>); @@ -32,6 +33,7 @@ fn main() { )); tauri::Builder::default() + .plugin(PluginBuilder::default().build()) .setup(|app| { let app_handle = app.app_handle(); tauri::async_runtime::spawn(async move { 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) => { |