organizing things and cracking problem with the polyfills i think?
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
// NOTE: DO NOT ADD ANY ELECTRON RELATED TYPESCRIPT HERE...KEEP IT ONLY TYPESCRIPT OTHERWISE
|
||||
// THE RENDERED WONT BE ABLE TO ACCESS THIS AS IT WILL THINK ITS PART OF MAIN PROCESS
|
||||
|
||||
enum Channels {
|
||||
ACTIVATE_LOG_IN = "ACTIVATE_LOG_IN",
|
||||
AUTH_TOKENS = "AUTH_TOKENS",
|
||||
}
|
||||
|
||||
export enum STORE_ITEMS {
|
||||
AUTH_TOKENS = "AUTH_TOKENS",
|
||||
}
|
||||
|
||||
export default Channels;
|
||||
|
||||
+11
-1
@@ -3,6 +3,16 @@ import { electronAPI } from "./preload";
|
||||
export {};
|
||||
declare global {
|
||||
interface Window {
|
||||
electronAPI: typeof electronAPI;
|
||||
electronAPI: {
|
||||
auth: {
|
||||
initiateLogin(): void;
|
||||
};
|
||||
store: {
|
||||
get(val: STORE_ITEMS): any;
|
||||
set(property: STORE_ITEMS, val: any): void;
|
||||
};
|
||||
on(channel: Channels, func: any): void;
|
||||
once(channel: Channels, func: any): void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import store, { STORE_ITEMS } from "./store";
|
||||
import Channels, { STORE_ITEMS } from "./constants";
|
||||
|
||||
import Channels from "./constants";
|
||||
import ElectronGoogleOAuth2 from "@getstation/electron-google-oauth2";
|
||||
import { browserWindow } from "../index";
|
||||
import { ipcMain } from "electron";
|
||||
import store from "./store";
|
||||
|
||||
const myApiOauth = new ElectronGoogleOAuth2(
|
||||
"423533244953-banligobgbof8hg89i6cr1l7u0p7c2pk.apps.googleusercontent.com",
|
||||
@@ -12,6 +12,7 @@ const myApiOauth = new ElectronGoogleOAuth2(
|
||||
{ successRedirectURL: "https://usenirvana.com" }
|
||||
);
|
||||
|
||||
// FRESH LOGIN...either tokens of user expired or never had them
|
||||
export async function handleLogin() {
|
||||
// read saved refresh token if any
|
||||
// todo: fix this...should be working
|
||||
|
||||
@@ -1,26 +1,42 @@
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
|
||||
import Channels from "./constants";
|
||||
import { STORE_ITEMS } from "./store";
|
||||
import { STORE_ITEMS } from "./constants";
|
||||
|
||||
const electronAPI = {
|
||||
auth: {
|
||||
initiateLogin() {
|
||||
ipcRenderer.send(Channels.ACTIVATE_LOG_IN);
|
||||
},
|
||||
receiveTokens(channel: Channels, func: any) {
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
},
|
||||
},
|
||||
store: {
|
||||
get(val: STORE_ITEMS) {
|
||||
return ipcRenderer.sendSync("electron-store-get", val);
|
||||
return ipcRenderer.invoke("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.
|
||||
},
|
||||
|
||||
on(channel: Channels, func: any) {
|
||||
const validChannels = ["ipc-example"];
|
||||
// if (validChannels.includes(channel)) {
|
||||
// // Deliberately strip event as it includes `sender`
|
||||
// ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
// }
|
||||
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
},
|
||||
once(channel: Channels, func: any) {
|
||||
// const validChannels = ["ipc-example"];
|
||||
// if (validChannels.includes(channel)) {
|
||||
// // Deliberately strip event as it includes `sender`
|
||||
// ipcRenderer.once(channel, (event, ...args) => func(...args));
|
||||
// }
|
||||
|
||||
ipcRenderer.once(channel, (event, ...args) => func(...args));
|
||||
},
|
||||
};
|
||||
|
||||
contextBridge.exposeInMainWorld("electronAPI", electronAPI);
|
||||
|
||||
@@ -2,8 +2,4 @@ import Store from "electron-store";
|
||||
import { ipcMain } from "electron";
|
||||
const store = new Store();
|
||||
|
||||
export enum STORE_ITEMS {
|
||||
AUTH_TOKENS = "AUTH_TOKENS",
|
||||
}
|
||||
|
||||
export default store;
|
||||
|
||||
Reference in New Issue
Block a user