Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(app-shell, app-shell-odd): Refactor app to use unsubscribe flags #14633

Closed
wants to merge 14 commits into from
Closed
Prev Previous commit
Next Next commit
Merge branch 'edge' into refactor-shell-notify-subscriptions
  • Loading branch information
mjhuff committed Mar 8, 2024
commit a1ad5d76558e5900c9ace91b5b55efeda73cd097
9 changes: 2 additions & 7 deletions app-shell-odd/src/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const pendingUnsubs = new Set<NotifyTopic>()
const log = createLogger('notify')
// MQTT is somewhat particular about the clientId format and will connect erratically if an unexpected string is supplied.
// This clientId is derived from the mqttjs library.
const CLIENT_ID = 'odd-' + Math.random().toString(16).slice(2, 8)
const CLIENT_ID = 'app-' + Math.random().toString(16).slice(2, 8)

const connectOptions: mqtt.IClientOptions = {
clientId: CLIENT_ID,
Expand Down Expand Up @@ -209,12 +209,7 @@ function subscribe(notifyParams: NotifyParams): Promise<void> {
if (counter === MAX_RETRIES) {
clearInterval(intervalId)
// log.warn(`Failed to subscribe on ${hostname} to topic: ${topic}`)
sendToBrowserDeserialized({
browserWindow,
hostname,
topic,
message: FAILURE_STATUSES.ECONNFAILED,
})
reject(new Error('Maximum subscription retries exceeded.'))
}
}, CHECK_CONNECTION_INTERVAL)
})
Expand Down
7 changes: 1 addition & 6 deletions app-shell/src/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,7 @@ function subscribe(notifyParams: NotifyParams): Promise<void> {
if (counter === MAX_RETRIES) {
clearInterval(intervalId)
// log.warn(`Failed to subscribe on ${hostname} to topic: ${topic}`)
sendToBrowserDeserialized({
browserWindow,
hostname,
topic,
message: FAILURE_STATUSES.ECONNFAILED,
})
reject(new Error('Maximum subscription retries exceeded.'))
}
}, CHECK_CONNECTION_INTERVAL)
})
Expand Down
7 changes: 6 additions & 1 deletion app/src/redux/shell/__tests__/actions.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { uiInitialized, notifySubscribeAction } from '../actions'
import { describe, it, expect } from 'vitest'

import {
uiInitialized,
notifySubscribeAction,
} from '../actions'

import type { NotifyTopic } from '../types'

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.