diff --git a/electron/main.js b/electron/main.js
index a1035a227..5216987e2 100644
--- a/electron/main.js
+++ b/electron/main.js
@@ -57,8 +57,12 @@ let appConfig = {
},
};
+/**
+ * @type {BrowserWindow}
+ */
+let mainWindow;
+
let tray,
- mainWindow,
splashWindow,
operateDaemon,
operateDaemonPid,
@@ -243,6 +247,14 @@ const createMainWindow = async () => {
showNotification(title, description || undefined);
});
+ // if app (ie. mainWindow) is loaded, destroy splash window.
+ ipcMain.on('is-app-loaded', (_event, isLoaded) => {
+ if (isLoaded && splashWindow) {
+ splashWindow.destroy();
+ splashWindow = null;
+ }
+ });
+
mainWindow.webContents.on('did-fail-load', () => {
mainWindow.webContents.reloadIgnoringCache();
});
@@ -261,7 +273,7 @@ const createMainWindow = async () => {
event.preventDefault();
mainWindow.hide();
});
-
+
try {
logger.electron('Setting up store IPC');
await setupStoreIpc(ipcMain, mainWindow);
@@ -337,7 +349,6 @@ async function launchDaemon() {
}
async function launchDaemonDev() {
-
const check = new Promise(function (resolve, _reject) {
operateDaemon = spawn('poetry', [
'run',
@@ -503,7 +514,6 @@ ipcMain.on('check', async function (event, _argument) {
event.sender.send('response', 'Launching App');
await createMainWindow();
createTray();
- splashWindow.destroy();
} catch (e) {
logger.electron(e);
new Notification({
@@ -522,6 +532,7 @@ app.on('ready', async () => {
path.join(__dirname, 'assets/icons/splash-robot-head-dock.png'),
);
}
+
createSplashWindow();
});
diff --git a/electron/preload.js b/electron/preload.js
index 2878e232e..562f49c72 100644
--- a/electron/preload.js
+++ b/electron/preload.js
@@ -1,6 +1,8 @@
const { contextBridge, ipcRenderer } = require('electron/renderer');
contextBridge.exposeInMainWorld('electronAPI', {
+ setIsAppLoaded: (isAppLoaded) =>
+ ipcRenderer.send('is-app-loaded', isAppLoaded),
closeApp: () => ipcRenderer.send('close-app'),
minimizeApp: () => ipcRenderer.send('minimize-app'),
setTrayIcon: (status) => ipcRenderer.send('tray', status),
diff --git a/frontend/components/SetupPage/SetupWelcome.tsx b/frontend/components/SetupPage/SetupWelcome.tsx
index b12c2ebfa..9d3c3b3d8 100644
--- a/frontend/components/SetupPage/SetupWelcome.tsx
+++ b/frontend/components/SetupPage/SetupWelcome.tsx
@@ -39,12 +39,13 @@ export const SetupWelcome = () => {
case true:
setIsSetup(AccountIsSetup.True);
break;
- case false:
+ case false: {
// Reset persistent state
// if creating new account
electronApi.store?.clear?.();
setIsSetup(AccountIsSetup.False);
break;
+ }
default:
setIsSetup(AccountIsSetup.Error);
break;
@@ -64,18 +65,27 @@ export const SetupWelcome = () => {
return ;
case AccountIsSetup.Loading:
return (
-
+
);
- default:
+ case AccountIsSetup.Error:
return (
-
+
- Error determining account setup state.
+ Unable to determine the account setup status, please try again.
);
+ default:
+ return null;
}
}, [isSetup]);
diff --git a/frontend/context/ElectronApiProvider.tsx b/frontend/context/ElectronApiProvider.tsx
index 01f85bdf9..7927bf7d4 100644
--- a/frontend/context/ElectronApiProvider.tsx
+++ b/frontend/context/ElectronApiProvider.tsx
@@ -4,6 +4,7 @@ import { createContext, PropsWithChildren } from 'react';
import { ElectronStore, ElectronTrayIconStatus } from '@/types/ElectronApi';
type ElectronApiContextProps = {
+ setIsAppLoaded?: (isLoaded: boolean) => void;
closeApp?: () => void;
minimizeApp?: () => void;
setTrayIcon?: (status: ElectronTrayIconStatus) => void;
@@ -33,6 +34,7 @@ type ElectronApiContextProps = {
};
export const ElectronApiContext = createContext({
+ setIsAppLoaded: () => false,
closeApp: () => {},
minimizeApp: () => {},
setTrayIcon: () => {},
@@ -70,6 +72,7 @@ export const ElectronApiProvider = ({ children }: PropsWithChildren) => {
return (
{
+ // Notify the main process that the app is loaded
+ electronApi?.setIsAppLoaded?.(true);
+
+ // Set the app height to the body scroll height
function updateAppHeight() {
const bodyElement = document.querySelector('body');
if (bodyElement) {