removed dependencies on electron remote

This commit is contained in:
Jan Prochazka
2021-12-16 15:41:34 +01:00
parent 588b8b23f9
commit 3d841ef8fe
15 changed files with 87 additions and 54 deletions

View File

@@ -8,9 +8,28 @@ class ElectronApi {
this.authorization = args.authorization;
}
send(msg, args) {
send(msg, args = null) {
this.ipcRenderer.send(msg, args);
}
async showOpenDialog(options) {
const res = await this.ipcRenderer.invoke('showOpenDialog', options);
return res;
}
async showSaveDialog(options) {
const res = await this.ipcRenderer.invoke('showSaveDialog', options);
return res;
}
async showItemInFolder(path) {
const res = await this.ipcRenderer.invoke('showItemInFolder', path);
return res;
}
async openExternal(url) {
await this.ipcRenderer.invoke('openExternal', url);
}
}
let apiInstance = null;
@@ -39,6 +58,10 @@ export function shouldWaitForElectronInitialize() {
return !!getIpcRenderer() && !apiInstance;
}
export function isElectronAvailable() {
return !!getIpcRenderer();
}
export default function getElectron(): ElectronApi {
return apiInstance;
// try {