Move alerts to their own page, add direct message alerts

This commit is contained in:
Jon Staab
2025-09-09 09:54:08 -07:00
parent 69bd6d0e70
commit fc6a1a3819
22 changed files with 592 additions and 310 deletions
+29
View File
@@ -21,6 +21,7 @@ import {
identity,
groupBy,
always,
tryCatch,
} from "@welshman/lib"
import type {Socket} from "@welshman/net"
import {Pool, load, AuthStateEvent, SocketEvent, netContext} from "@welshman/net"
@@ -32,6 +33,7 @@ import {
withGetter,
synced,
} from "@welshman/store"
import {isKindFeed, findFeed} from "@welshman/feeds"
import {
getIdFilters,
WRAP,
@@ -70,6 +72,8 @@ import {
getTagValues,
verifyEvent,
makeEvent,
RelayMode,
getRelaysFromList,
} from "@welshman/util"
import type {TrustedEvent, SignedEvent, PublishedList, List, Filter} from "@welshman/util"
import {Nip59, decrypt} from "@welshman/signer"
@@ -94,6 +98,8 @@ import {
appContext,
getThunkError,
publishThunk,
userRelaySelections,
userInboxRelaySelections,
} from "@welshman/app"
import type {Thunk, Relay} from "@welshman/app"
import {preferencesStorageProvider} from "@src/lib/storage"
@@ -375,6 +381,18 @@ export const relaysPendingTrust = writable<string[]>([])
export const relaysMostlyRestricted = writable<Record<string, string>>({})
// Relay selections
export const userReadRelays = derived(userRelaySelections, $l =>
getRelaysFromList($l, RelayMode.Read),
)
export const userWriteRelays = derived(userRelaySelections, $l =>
getRelaysFromList($l, RelayMode.Write),
)
export const userInboxRelays = derived(userInboxRelaySelections, $l => getRelaysFromList($l))
// Alerts
export type Alert = {
@@ -394,6 +412,17 @@ export const alerts = withGetter(
}),
)
export const getAlertFeed = (alert: Alert) =>
tryCatch(() => JSON.parse(getTagValue("feed", alert.tags)!))
export const dmAlert = derived(alerts, $alerts =>
$alerts.find(alert => {
const feed = getAlertFeed(alert)
return findFeed(feed, f => isKindFeed(f) && f.includes(WRAP))
}),
)
// Alert Statuses
export type AlertStatus = {