From 4bc3b013bb484cb714d23da3e90fe76a8a71db6a Mon Sep 17 00:00:00 2001 From: Wizzard Date: Sat, 9 Mar 2024 02:52:10 -0500 Subject: [PATCH] Restart GUI when we get API key --- gui/kuzco-gui.js | 5 ++++- gui/preload.js | 5 +---- gui/prompt.html | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gui/kuzco-gui.js b/gui/kuzco-gui.js index 3ae6b6c..8498e56 100644 --- a/gui/kuzco-gui.js +++ b/gui/kuzco-gui.js @@ -32,7 +32,10 @@ ipcMain.on('submit-api-key', (event, apiKey) => { } fs.writeFileSync(configPath, JSON.stringify({ API_KEY: apiKey }, null, 2), 'utf8'); - event.sender.send('api-key-saved'); + event.reply('api-key-saved'); + + app.relaunch(); + app.quit(); }); diff --git a/gui/preload.js b/gui/preload.js index 3b8b718..047a9d4 100644 --- a/gui/preload.js +++ b/gui/preload.js @@ -2,8 +2,5 @@ const { contextBridge, ipcRenderer } = require('electron'); contextBridge.exposeInMainWorld('electronAPI', { sendPrompt: (prompt) => ipcRenderer.invoke('send-prompt', prompt), + onApiKeySaved: (callback) => ipcRenderer.on('api-key-saved', callback), }); - -contextBridge.exposeInMainWorld('api', { - submitApiKey: (apiKey) => ipcRenderer.send('submit-api-key', apiKey) -}); \ No newline at end of file diff --git a/gui/prompt.html b/gui/prompt.html index f1154c3..0087191 100644 --- a/gui/prompt.html +++ b/gui/prompt.html @@ -2,6 +2,7 @@ Enter API Key +

Enter API Key

@@ -16,4 +17,4 @@ }); - + \ No newline at end of file