Fix error opening context menus (#2808)

Fixes AB#25223318
This commit is contained in:
David Watrous 2023-10-02 16:36:05 -04:00 коммит произвёл Shiran Pasternak
Родитель 3bb271641c
Коммит 82b3e71ba5
1 изменённых файлов: 17 добавлений и 4 удалений

Просмотреть файл

@ -1,5 +1,12 @@
import { Injectable } from "@angular/core";
import { IpcService } from "./ipc.service";
import type {
Menu as RemoteMenu,
MenuItem as RemoteMenuItem,
dialog as RemoteDialog,
app as RemoteApp,
getCurrentWindow as remoteGetCurrentWindow
} from "@electron/remote";
// Uncomment bellow to check sendSync performance issues
// let total = 0;
@ -13,18 +20,24 @@ import { IpcService } from "./ipc.service";
// return result;
// };
type ElectronRemoteModule = {
Menu: typeof RemoteMenu,
MenuItem: typeof RemoteMenuItem,
dialog: typeof RemoteDialog,
app: typeof RemoteApp,
getCurrentWindow: typeof remoteGetCurrentWindow
}
/**
* Injectable service wrapping electron shell.
* This makes it easier to mock the electron shell.
*/
@Injectable()
export class ElectronRemote {
// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match
public Menu: typeof Electron.Menu;
// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match
public MenuItem: typeof Electron.MenuItem;
private _remote;
private _remote: ElectronRemoteModule;
constructor(private ipc: IpcService) {
// Require here because importing @electron/remote fails for client
@ -32,7 +45,7 @@ export class ElectronRemote {
// eslint-disable-next-line @typescript-eslint/no-var-requires
this._remote = require("@electron/remote");
this.Menu = this._remote.RemoteMenu;
this.Menu = this._remote.Menu;
this.MenuItem = this._remote.MenuItem;
}