diff --git a/openpilot/starpilot/galaxy/web/js/sentry-notifications.js b/openpilot/starpilot/galaxy/web/js/sentry-notifications.js index 4bb103800e..adf9ec4d18 100644 --- a/openpilot/starpilot/galaxy/web/js/sentry-notifications.js +++ b/openpilot/starpilot/galaxy/web/js/sentry-notifications.js @@ -62,6 +62,7 @@ export const SentryNotifications = { name: "SentryNotifications", props: { mode: { type: String, required: true }, unauthorized: { type: Function, required: true } }, data: () => ({ nativePush: !!window.StarPilotApp?.sentryPush, pushState: {}, testPoll: null, relayUrl: '', enrollmentCode: '', relayConfirmed: false, channels, labels, notifications: null, notificationBusy: false, notificationError: "", + channelSetup: {}, drafts: Object.fromEntries(channels.map(name => [name, { url: "", token: "" }])) }), created() { this.client = new NotificationClient({ publish: update => Object.assign(this.$data, update), unauthorized: this.unauthorized }) }, mounted() { @@ -116,16 +117,25 @@ export const SentryNotifications = { this.client.run() this.poll = setInterval(() => { if (!this.notificationBusy && !this.client.pending) this.client.run() }, 5000) }, + channelExpanded(name) { return this.notifications.channels[name].enabled || !!this.channelSetup[name] }, + toggleChannel(name) { + if (!this.notifications.channels[name].configured) { + this.channelSetup[name] = !this.channelSetup[name] + return + } + return this.reportSave(() => this.save(name, !this.notifications.channels[name].enabled)) + }, async save(name, enabled) { const draft = this.drafts[name] const saved = await this.client.run({ action: "configure", channel: name, enabled, url: draft.url, token: draft.token }) if (saved) { draft.url = ""; draft.token = "" + this.channelSetup[name] = false } return saved }, test(name) { return this.client.run({ action: "test", channel: name }) }, - async forget(name) { if (await this.client.run({ action: "forget", channel: name })) { this.drafts[name].url = ""; this.drafts[name].token = "" } }, + async forget(name) { if (await this.client.run({ action: "forget", channel: name })) { this.drafts[name].url = ""; this.drafts[name].token = ""; this.channelSetup[name] = false } }, remove(id) { return this.client.run({ action: "unsubscribe", id }) }, async subscribe() { if (!isSecureContext || !("serviceWorker" in navigator) || !("PushManager" in window)) { @@ -215,10 +225,10 @@ export const SentryNotifications = {
{{ notifications.channels[name].configured ? 'Configured' : 'Not configured' }}, last delivery {{ notifications.channels[name].lastState }}, {{ notifications.channels[name].pending }} pending