From 5769cf80f07e3457bb10764cd4d5655a17904b84 Mon Sep 17 00:00:00 2001 From: abose Date: Tue, 26 Dec 2023 15:16:38 +0530 Subject: [PATCH] fix: default project not created on first boot --- src/index.html | 1 - src/storage.js | 10 ++++++++++ test/SpecRunner.html | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index.html b/src/index.html index f5eeba8c4..5e7db22e2 100644 --- a/src/index.html +++ b/src/index.html @@ -119,7 +119,6 @@ window._tauriStorageRestorePromise = window.__TAURI__.fs.readTextFile( "storageDB/storageDBDump.json", { dir: window.__TAURI__.fs.BaseDirectory.AppLocalData }) .catch(err =>{ - window.Phoenix.firstBoot = true; console.error("First boot detected or Failed to init storage from cache." + " If first boot, ignore this error", err); }); diff --git a/src/storage.js b/src/storage.js index fba0288c2..d929f2977 100644 --- a/src/storage.js +++ b/src/storage.js @@ -51,6 +51,7 @@ return; } const EVENT_CHANGED = "change"; + const FIRST_BOOT_TIME = "firstBootTime"; let storageNodeConnector; let _testKey; let nodeStoragePhoenixApis = {}; @@ -220,12 +221,20 @@ } } + function setupFirstBoot() { + const firstBootTime = getItem(FIRST_BOOT_TIME); + if(!firstBootTime){ + window.Phoenix.firstBoot = true; + setItem(FIRST_BOOT_TIME, Date.now()); + } + } const storageReadyPromise = new Promise((resolve) => { if(isBrowser || Phoenix.isTestWindow){ // in browsers its immediately ready as we use localstorage // in tests, immediately resolve with empty storage. resolve(); + setupFirstBoot(); return; } // In tauri, we have to read it from app local data dump(which is usually written at app close time. This @@ -233,6 +242,7 @@ window._tauriStorageRestorePromise .then((jsonData)=>{ cache = JSON.parse(jsonData); + setupFirstBoot(); }) .finally(resolve); }); diff --git a/test/SpecRunner.html b/test/SpecRunner.html index c783c2bb8..0ba248516 100644 --- a/test/SpecRunner.html +++ b/test/SpecRunner.html @@ -107,7 +107,6 @@ window._tauriStorageRestorePromise = window.__TAURI__.fs.readTextFile( "storageDB/storageDBDump.json", { dir: window.__TAURI__.fs.BaseDirectory.AppLocalData }) .catch(err =>{ - window.Phoenix.firstBoot = true; console.error("First boot detected or Failed to init storage from cache." + " If first boot, ignore this error", err); });