aboutsummaryrefslogtreecommitdiff
path: root/src-vue
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2022-10-18 23:33:38 +0200
committerGitHub <noreply@github.com>2022-10-18 23:33:38 +0200
commit546d1908b15fc7c21b1b5f0109826fb03a5493fd (patch)
treec44daa3d0e550eaa3ff1397909bbc9564012d53f /src-vue
parentc4ce52bb45f0dcda8ea924694b48a8e0501d57c0 (diff)
downloadFlightCore-546d1908b15fc7c21b1b5f0109826fb03a5493fd.tar.gz
FlightCore-546d1908b15fc7c21b1b5f0109826fb03a5493fd.zip
feat: Add persistent store (#16)
* refactor: Rename object field So that is specifically references Northstar * chore: Add plugin-store as npm dependency * feat: Persistent storing selected NS release canal * docs: Add explanation about persistent store
Diffstat (limited to 'src-vue')
-rw-r--r--src-vue/package-lock.json47
-rw-r--r--src-vue/package.json1
-rw-r--r--src-vue/src/plugins/store.ts23
-rw-r--r--src-vue/src/views/DeveloperView.vue11
4 files changed, 74 insertions, 8 deletions
diff --git a/src-vue/package-lock.json b/src-vue/package-lock.json
index 1c2d8d0c..bcae0ab6 100644
--- a/src-vue/package-lock.json
+++ b/src-vue/package-lock.json
@@ -10,6 +10,7 @@
"dependencies": {
"@element-plus/icons-vue": "^2.0.9",
"element-plus": "^2.2.17",
+ "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#dev",
"vue": "^3.2.37",
"vuex": "^4.0.2"
},
@@ -105,6 +106,20 @@
"url": "https://opencollective.com/popperjs"
}
},
+ "node_modules/@tauri-apps/api": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-1.1.0.tgz",
+ "integrity": "sha512-n13pIqdPd3KtaMmmAcrU7BTfdMtIlGNnfZD0dNX8L4p8dgmuNyikm6JAA+yCpl9gqq6I8x5cV2Y0muqdgD0cWw==",
+ "engines": {
+ "node": ">= 12.22.0",
+ "npm": ">= 6.6.0",
+ "yarn": ">= 1.19.1"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/tauri"
+ }
+ },
"node_modules/@types/lodash": {
"version": "4.14.185",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.185.tgz",
@@ -1036,6 +1051,20 @@
"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#4326f75446b8b9e0cb9904c65f258b81e23e544e",
+ "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=="
+ },
"node_modules/typescript": {
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
@@ -1188,6 +1217,11 @@
"resolved": "https://registry.npmjs.org/@sxzz/popperjs-es/-/popperjs-es-2.11.7.tgz",
"integrity": "sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ=="
},
+ "@tauri-apps/api": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-1.1.0.tgz",
+ "integrity": "sha512-n13pIqdPd3KtaMmmAcrU7BTfdMtIlGNnfZD0dNX8L4p8dgmuNyikm6JAA+yCpl9gqq6I8x5cV2Y0muqdgD0cWw=="
+ },
"@types/lodash": {
"version": "4.14.185",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.185.tgz",
@@ -1804,6 +1838,19 @@
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"dev": true
},
+ "tauri-plugin-store-api": {
+ "version": "git+ssh://git@github.com/tauri-apps/tauri-plugin-store.git#4326f75446b8b9e0cb9904c65f258b81e23e544e",
+ "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=="
+ },
"typescript": {
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
diff --git a/src-vue/package.json b/src-vue/package.json
index 78d7093b..8f53ad27 100644
--- a/src-vue/package.json
+++ b/src-vue/package.json
@@ -11,6 +11,7 @@
"dependencies": {
"@element-plus/icons-vue": "^2.0.9",
"element-plus": "^2.2.17",
+ "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#dev",
"vue": "^3.2.37",
"vuex": "^4.0.2"
},
diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts
index de66da3f..647ee4e9 100644
--- a/src-vue/src/plugins/store.ts
+++ b/src-vue/src/plugins/store.ts
@@ -7,6 +7,9 @@ import { GameInstall } from "../utils/GameInstall";
import { ReleaseCanal } from "../utils/ReleaseCanal";
import { ElNotification } from 'element-plus';
import { NorthstarState } from '../utils/NorthstarState';
+import { Store } from 'tauri-plugin-store-api';
+
+const persistentStore = new Store('flight-core-settings.json');
export interface FlightCoreStore {
@@ -19,7 +22,7 @@ export interface FlightCoreStore {
installed_northstar_version: string,
northstar_state: NorthstarState,
- release_canal: ReleaseCanal,
+ northstar_release_canal: ReleaseCanal,
northstar_is_running: boolean,
origin_is_running: boolean
@@ -37,7 +40,7 @@ export const store = createStore<FlightCoreStore>({
installed_northstar_version: "",
northstar_state: NorthstarState.GAME_NOT_FOUND,
- release_canal: ReleaseCanal.RELEASE,
+ northstar_release_canal: ReleaseCanal.RELEASE,
northstar_is_running: false,
origin_is_running: false
@@ -68,7 +71,7 @@ export const store = createStore<FlightCoreStore>({
switch (state.northstar_state) {
// Install northstar if it wasn't detected.
case NorthstarState.INSTALL:
- let install_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_path, northstarPackageName: state.release_canal });
+ let install_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_path, northstarPackageName: state.northstar_release_canal });
state.northstar_state = NorthstarState.INSTALLING;
await install_northstar_result.then((message) => {
@@ -85,7 +88,7 @@ export const store = createStore<FlightCoreStore>({
// Update northstar if it is outdated.
case NorthstarState.MUST_UPDATE:
// Updating is the same as installing, simply overwrites the existing files
- let reinstall_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_path, northstarPackageName: state.release_canal });
+ let reinstall_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_path, northstarPackageName: state.northstar_release_canal });
state.northstar_state = NorthstarState.UPDATING;
await reinstall_northstar_result.then((message) => {
@@ -143,6 +146,16 @@ async function _initializeApp(state: any) {
state.developer_mode = true;
}
+ // Grab Northstar release canal value from store if exists
+ var persistent_northstar_release_canal = (await persistentStore.get('northstar-release-canal')) as any;
+ if(persistent_northstar_release_canal) { // For some reason, the plugin-store doesn't throw an eror but simply returns `null` when key not found
+ // Put value from peristent store into current store
+ state.northstar_release_canal = persistent_northstar_release_canal.value as string;
+ }
+ else {
+ console.log("Value not found in store");
+ }
+
// Get FlightCore version number
state.flightcore_version = await invoke("get_version_number");
@@ -205,7 +218,7 @@ async function _get_northstar_version_number(state: any) {
state.installed_northstar_version = northstar_version_number;
state.northstar_state = NorthstarState.READY_TO_PLAY;
- await invoke("check_is_northstar_outdated", { gamePath: state.game_path, northstarPackageName: state.release_canal })
+ await invoke("check_is_northstar_outdated", { gamePath: state.game_path, northstarPackageName: state.northstar_release_canal })
.then((message) => {
if (message) {
state.northstar_state = NorthstarState.MUST_UPDATE;
diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue
index 92364679..80390432 100644
--- a/src-vue/src/views/DeveloperView.vue
+++ b/src-vue/src/views/DeveloperView.vue
@@ -31,6 +31,8 @@ import { invoke } from "@tauri-apps/api";
import { ElNotification } from "element-plus";
import { ReleaseCanal } from "../utils/ReleaseCanal";
import { GameInstall } from "../utils/GameInstall";
+import { Store } from 'tauri-plugin-store-api';
+const persistentStore = new Store('flight-core-settings.json');
export default defineComponent({
name: "DeveloperView",
@@ -67,10 +69,13 @@ export default defineComponent({
},
async toggleReleaseCandidate() {
// Flip between RELEASE and RELEASE_CANDIDATE
- this.$store.state.release_canal = this.$store.state.release_canal === ReleaseCanal.RELEASE
+ this.$store.state.northstar_release_canal = this.$store.state.northstar_release_canal === ReleaseCanal.RELEASE
? ReleaseCanal.RELEASE_CANDIDATE
: ReleaseCanal.RELEASE;
+ // Save change in persistent store
+ await persistentStore.set('northstar-release-canal', { value: this.$store.state.northstar_release_canal });
+
// Update current state so that update check etc can be performed
this.$store.commit("checkNorthstarUpdates");
@@ -78,8 +83,8 @@ export default defineComponent({
// Display notification to highlight change
ElNotification({
- title: `${this.$store.state.release_canal}`,
- message: `Switched release channel to: "${this.$store.state.release_canal}"`,
+ title: `${this.$store.state.northstar_release_canal}`,
+ message: `Switched release channel to: "${this.$store.state.northstar_release_canal}"`,
type: 'success',
position: 'bottom-right'
});