fix: guard deleteAlert and publishAlert against undefined relay
NOTIFIER_RELAY is string | undefined after the earlier guard fix. deleteAlert and publishAlert passed it directly to publish() which expects string[]. Add early-return guards to both functions. Fixes the 2 new TS2322 errors introduced by the previous commit.
This commit is contained in:
parent
57f7d94669
commit
4e6030f3c2
1 changed files with 7 additions and 2 deletions
|
|
@ -144,6 +144,8 @@ const loadAlerts = async () => {
|
|||
}
|
||||
|
||||
const deleteAlert = async (alert: Alert) => {
|
||||
if (!NOTIFIER_RELAY) return
|
||||
|
||||
if (confirm("Are you sure you want to delete this alert?")) {
|
||||
state.update(assoc('alertsLoading', true))
|
||||
|
||||
|
|
@ -207,8 +209,11 @@ export const makeAlert = async ({freq, time, email, feeds, secret}: AlertParams)
|
|||
)
|
||||
}
|
||||
|
||||
export const publishAlert = async (params: AlertParams) =>
|
||||
publish({event: await makeAlert(params), relays: [NOTIFIER_RELAY]})
|
||||
export const publishAlert = async (params: AlertParams) => {
|
||||
if (!NOTIFIER_RELAY) return
|
||||
|
||||
await publish({event: await makeAlert(params), relays: [NOTIFIER_RELAY]})
|
||||
}
|
||||
|
||||
// Components
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue