Adapt email notifications to upstream APIs post-merge
All checks were successful
CI / lint-check-build (pull_request) Successful in 4m38s

- mail adapter: publish kind 30390 / DELETE subscriptions via @app/core's
  Publisher (publisher.get().publish(...).settled()) instead of the removed
  thunks API; report first failure via getError().
- push/adapters/common.ts: import writable (used by emailNotificationState).
- prettier-format the merged settings.ts + alerts page.
This commit is contained in:
Agent 2026-10-01 17:21:53 -04:00
parent 91c17b5e0c
commit 72bb22a42f
4 changed files with 8 additions and 12 deletions

View file

@ -4,7 +4,7 @@ import {Address, DELETE, MESSAGE, makeEvent, makeHttpAuth, makeHttpAuthHeader} f
import {merged} from "@welshman/store"
import {Relays, User} from "@welshman/app"
import {buildUrl} from "@lib/util"
import {app, messagingRelayLists, roomLists, thunks} from "@app/core"
import {app, messagingRelayLists, publisher, roomLists} from "@app/core"
import {EMAIL_NOTIFICATION_SERVER, PUSH_BRIDGE} from "@app/env"
import {ensureEmailSalt, userSettingsValues} from "@app/settings"
import {emailNotificationState} from "@app/push/adapters/common"
@ -376,7 +376,7 @@ export class MailNotifications {
const identifier = await this._getSubscriptionIdentifier(relay, key)
const thunk = thunks.get().publish({
const publication = publisher.get().publish({
relays: [url],
event: makeEvent(30390, {
tags: [
@ -389,8 +389,8 @@ export class MailNotifications {
],
}),
})
const error = await thunk.waitForError()
await publication.settled()
const error = publication.getError()
if (error) {
console.warn(`Failed to subscribe ${relay} to email notifications:`, error)
}
@ -406,11 +406,9 @@ export class MailNotifications {
const identifier = await this._getSubscriptionIdentifier(relay, key)
const address = new Address(30390, $pubkey, identifier).toString()
const event = makeEvent(DELETE, {tags: [["a", address]]})
const error = await thunks
.get()
.publish({relays: [url], event})
.waitForError()
const publication = publisher.get().publish({relays: [url], event})
await publication.settled()
const error = publication.getError()
if (error) {
console.warn(`Failed to unsubscribe ${relay} from email notifications:`, error)
}

View file

@ -1,4 +1,4 @@
import type {Subscriber, Unsubscriber} from "svelte/store"
import {writable, type Subscriber, type Unsubscriber} from "svelte/store"
import {Capacitor} from "@capacitor/core"
import {call, ms, now, on, parseJson, poll, spec, throttle, uniq} from "@welshman/lib"
import {LOCAL_RELAY_URL} from "@welshman/net"

View file

@ -196,7 +196,6 @@ export const notificationSettings = withGetter(
}),
)
export const publishSettings = async (params: Partial<SettingsValues>) => {
const $app = app.get()
const reader = await settings.get().forceLoad(User.require($app).pubkey)

View file

@ -147,7 +147,6 @@
} catch (e) {
console.error(e)
pushToast({theme: "error", message: "Failed to save your alert settings."})
} finally {
loading = false
}