From 417b4027d05ea97209d57a31cdf9be111d3bed19 Mon Sep 17 00:00:00 2001 From: Jamey Huffnagle Date: Wed, 13 Mar 2024 14:17:31 -0400 Subject: [PATCH] we don't need to pass in browserWindow now --- app-shell/src/notify.ts | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/app-shell/src/notify.ts b/app-shell/src/notify.ts index c9134a5f9bf..98c164b078c 100644 --- a/app-shell/src/notify.ts +++ b/app-shell/src/notify.ts @@ -129,7 +129,7 @@ export function handleNotificationConnectionsFor( subscriptions: new Set(), pendingSubs: new Set(), } - establishListeners({ client, browserWindow, hostname }) + establishListeners({ client, hostname }) }) .catch((error: Error) => { log.warn( @@ -154,7 +154,6 @@ function subscribe(notifyParams: NotifyParams): Promise { if (unreachableHosts.has(hostname)) { const errorMessage = determineErrorMessageFor(hostname) sendToBrowserDeserialized({ - browserWindow, hostname, topic, message: errorMessage, @@ -177,7 +176,6 @@ function subscribe(notifyParams: NotifyParams): Promise { (error: Error) => { log.debug(error.message) sendToBrowserDeserialized({ - browserWindow, hostname, topic, message: FAILURE_STATUSES.ECONNFAILED, @@ -190,7 +188,6 @@ function subscribe(notifyParams: NotifyParams): Promise { .catch((error: Error) => { log.debug(error.message) sendToBrowserDeserialized({ - browserWindow, hostname, topic, message: FAILURE_STATUSES.ECONNFAILED, @@ -213,7 +210,6 @@ function subscribe(notifyParams: NotifyParams): Promise { const { subscriptions } = connectionStore[hostname] if (error != null) { sendToBrowserDeserialized({ - browserWindow, hostname, topic, message: FAILURE_STATUSES.ECONNFAILED, @@ -329,7 +325,6 @@ function connectAsync(brokerURL: string): Promise { interface ListenerParams { client: mqtt.MqttClient - browserWindow: BrowserWindow hostname: string } @@ -345,12 +340,14 @@ function establishListeners({ client, hostname }: ListenerParams): void { hostname, topic, }) - browserWindow.webContents.send( - 'notify', - hostname, - topic, - deserializedMessage - ) + try { + browserWindow.webContents.send( + 'notify', + hostname, + topic, + deserializedMessage + ) + } catch {} }) .catch(error => log.debug(`${error.message}`)) } @@ -363,7 +360,6 @@ function establishListeners({ client, hostname }: ListenerParams): void { client.on('error', error => { log.warn(`Error - ${error.name}: ${error.message}`) sendToBrowserDeserialized({ - browserWindow, hostname, topic: 'ALL_TOPICS', message: FAILURE_STATUSES.ECONNFAILED, @@ -374,7 +370,6 @@ function establishListeners({ client, hostname }: ListenerParams): void { client.on('end', () => { log.debug(`Closed connection to ${hostname}`) sendToBrowserDeserialized({ - browserWindow, hostname, topic: 'ALL_TOPICS', message: FAILURE_STATUSES.ECONNFAILED, @@ -388,7 +383,6 @@ function establishListeners({ client, hostname }: ListenerParams): void { }` ) sendToBrowserDeserialized({ - browserWindow, hostname, topic: 'ALL_TOPICS', message: FAILURE_STATUSES.ECONNFAILED, @@ -420,14 +414,12 @@ function closeConnectionsForcefullyFor(hosts: string[]): Array> { } interface SendToBrowserParams { - browserWindow: BrowserWindow hostname: string topic: NotifyTopic message: NotifyResponseData } function sendToBrowserDeserialized({ - browserWindow, hostname, topic, message,