mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
[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) => {
|
onSystemThemeUpdated: (callback: (theme: ThemeType) => void) => {
|
||||||
ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) => callback(theme));
|
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 {
|
function deviceType(): DeviceType {
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
import { ipcRenderer } from "electron";
|
|
||||||
|
|
||||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
|
|
||||||
export class ElectronRendererMessagingService implements MessagingService {
|
export class ElectronRendererMessagingService implements MessagingService {
|
||||||
constructor(private broadcasterService: BroadcasterService) {
|
constructor(private broadcasterService: BroadcasterService) {
|
||||||
ipcRenderer.on("messagingService", async (event: any, message: any) => {
|
ipc.platform.onMessage((message) => this.sendMessage(message.command, message, false));
|
||||||
if (message.command) {
|
|
||||||
this.sendMessage(message.command, message, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
send(subscriber: string, arg: any = {}) {
|
send(subscriber: string, arg: any = {}) {
|
||||||
@ -20,7 +14,7 @@ export class ElectronRendererMessagingService implements MessagingService {
|
|||||||
const message = Object.assign({}, { command: subscriber }, arg);
|
const message = Object.assign({}, { command: subscriber }, arg);
|
||||||
this.broadcasterService.send(message);
|
this.broadcasterService.send(message);
|
||||||
if (toMain) {
|
if (toMain) {
|
||||||
ipcRenderer.send("messagingService", message);
|
ipc.platform.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user