[PM-3684] Remove ipcRenderer from electron.renderer.messaging (#6480)
This commit is contained in:
parent
d79ef473c6
commit
1f26f6579d
|
@ -17,6 +17,16 @@ export default {
|
|||
onSystemThemeUpdated: (callback: (theme: ThemeType) => void) => {
|
||||
ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) => callback(theme));
|
||||
},
|
||||
|
||||
sendMessage: (message: { command: string } & any) =>
|
||||
ipcRenderer.send("messagingService", message),
|
||||
onMessage: (callback: (message: { command: string } & any) => void) => {
|
||||
ipcRenderer.on("messagingService", (_event, message: any) => {
|
||||
if (message.command) {
|
||||
callback(message);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
function deviceType(): DeviceType {
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
import { ipcRenderer } from "electron";
|
||||
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
|
||||
export class ElectronRendererMessagingService implements MessagingService {
|
||||
constructor(private broadcasterService: BroadcasterService) {
|
||||
ipcRenderer.on("messagingService", async (event: any, message: any) => {
|
||||
if (message.command) {
|
||||
this.sendMessage(message.command, message, false);
|
||||
}
|
||||
});
|
||||
ipc.platform.onMessage((message) => this.sendMessage(message.command, message, false));
|
||||
}
|
||||
|
||||
send(subscriber: string, arg: any = {}) {
|
||||
|
@ -20,7 +14,7 @@ export class ElectronRendererMessagingService implements MessagingService {
|
|||
const message = Object.assign({}, { command: subscriber }, arg);
|
||||
this.broadcasterService.send(message);
|
||||
if (toMain) {
|
||||
ipcRenderer.send("messagingService", message);
|
||||
ipc.platform.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue