diff --git a/src/app/mail/index.ts b/src/app/mail/index.ts index 993ed91a..b12b6dde 100644 --- a/src/app/mail/index.ts +++ b/src/app/mail/index.ts @@ -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) } diff --git a/src/app/push/adapters/common.ts b/src/app/push/adapters/common.ts index e9ee686c..4a8afa6b 100644 --- a/src/app/push/adapters/common.ts +++ b/src/app/push/adapters/common.ts @@ -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" diff --git a/src/app/settings.ts b/src/app/settings.ts index 69361f79..800fd2de 100644 --- a/src/app/settings.ts +++ b/src/app/settings.ts @@ -196,7 +196,6 @@ export const notificationSettings = withGetter( }), ) - export const publishSettings = async (params: Partial) => { const $app = app.get() const reader = await settings.get().forceLoad(User.require($app).pubkey) diff --git a/src/routes/settings/alerts/+page.svelte b/src/routes/settings/alerts/+page.svelte index 1d60f9a5..6a92eb3d 100644 --- a/src/routes/settings/alerts/+page.svelte +++ b/src/routes/settings/alerts/+page.svelte @@ -147,7 +147,6 @@ } catch (e) { console.error(e) pushToast({theme: "error", message: "Failed to save your alert settings."}) - } finally { loading = false }