diff options
Diffstat (limited to 'src-vue/src/plugins/store.ts')
-rw-r--r-- | src-vue/src/plugins/store.ts | 23 |
1 files changed, 18 insertions, 5 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; |