dont send message back to main if that's where it came from originally

This commit is contained in:
Kyle Spearrin 2018-05-08 10:29:19 -04:00
parent 3270d8bd0e
commit e7779759f2
1 changed files with 8 additions and 2 deletions

View File

@ -8,14 +8,20 @@ export class ElectronRendererMessagingService implements MessagingService {
constructor(private broadcasterService: BroadcasterService) {
ipcRenderer.on('messagingService', async (event: any, message: any) => {
if (message.command) {
this.send(message.command, message);
this.sendMessage(message.command, message, false);
}
});
}
send(subscriber: string, arg: any = {}) {
this.sendMessage(subscriber, arg, true);
}
private sendMessage(subscriber: string, arg: any = {}, toMain: boolean) {
const message = Object.assign({}, { command: subscriber }, arg);
ipcRenderer.send('messagingService', message);
this.broadcasterService.send(message);
if (toMain) {
ipcRenderer.send('messagingService', message);
}
}
}