Skip to content

Commit

Permalink
Fix error opening context menus (#2808)
Browse files Browse the repository at this point in the history
Fixes AB#25223318
  • Loading branch information
dpwatrous authored Oct 2, 2023
1 parent 637891a commit e04d7a6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions desktop/src/@batch-flask/electron/remote.service.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,26 +20,32 @@ 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
// unit tests
// 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;
}

Expand Down

0 comments on commit e04d7a6

Please sign in to comment.