aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src
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/src
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/src')
-rw-r--r--src-vue/src/plugins/store.ts23
-rw-r--r--src-vue/src/views/DeveloperView.vue11
2 files changed, 26 insertions, 8 deletions
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'
});