forked from coracle/flotilla
Move alerts to their own page, add direct message alerts
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user