adding in global store access but not done

This commit is contained in:
talksik
2022-03-18 11:02:56 -04:00
parent 478b785145
commit 18a50cd121
2 changed files with 18 additions and 2 deletions
+10 -2
View File
@@ -1,6 +1,7 @@
import { contextBridge, ipcRenderer } from "electron"; import { contextBridge, ipcRenderer } from "electron";
import Channels from "./constants"; import Channels from "./constants";
import { STORE_ITEMS } from "./store";
const electronAPI = { const electronAPI = {
auth: { auth: {
@@ -11,8 +12,15 @@ const electronAPI = {
ipcRenderer.on(channel, (event, ...args) => func(...args)); ipcRenderer.on(channel, (event, ...args) => func(...args));
}, },
}, },
batteryApi: {}, store: {
fileApi: {}, get(val: STORE_ITEMS) {
return ipcRenderer.sendSync("electron-store-get", val);
},
set(property: STORE_ITEMS, val: any) {
ipcRenderer.send("electron-store-set", property, val);
},
// Other method you want to add like has(), reset(), etc.
},
}; };
contextBridge.exposeInMainWorld("electronAPI", electronAPI); contextBridge.exposeInMainWorld("electronAPI", electronAPI);
+8
View File
@@ -49,6 +49,14 @@ app
console.log("initiating log in"); console.log("initiating log in");
await handleLogin(); await handleLogin();
}); });
// IPC listener
ipcMain.on("electron-store-get", async (event, val) => {
event.returnValue = store.get(val);
});
ipcMain.on("electron-store-set", async (event, key, val) => {
store.set(key, val);
});
}); });
// Quit when all windows are closed, except on macOS. There, it's common // Quit when all windows are closed, except on macOS. There, it's common