Rework alert settings and UI

This commit is contained in:
Jon Staab
2026-01-30 08:41:58 -08:00
parent ee48072137
commit 4169db33e6
17 changed files with 315 additions and 297 deletions
+23 -2
View File
@@ -271,6 +271,12 @@ export enum RelayAuthMode {
Conservative = "conservative",
}
export type SpaceNotificationSettings = {
url: string
notify: boolean
exceptions: string[]
}
export type SettingsValues = {
show_media: boolean
hide_sensitive: boolean
@@ -280,7 +286,7 @@ export type SettingsValues = {
relay_auth: RelayAuthMode
send_delay: number
font_size: number
muted_rooms: string[]
alerts: SpaceNotificationSettings[]
}
export type Settings = {
@@ -297,7 +303,7 @@ export const defaultSettings: SettingsValues = {
relay_auth: RelayAuthMode.Conservative,
send_delay: 0,
font_size: 1.1,
muted_rooms: [],
alerts: [],
}
export const settingsByPubkey = deriveItemsByKey({
@@ -993,3 +999,18 @@ export const parseInviteLink = (invite: string): InviteData | undefined => {
})
)
}
// Hierarchical notification helpers
export const isMuted = (url: string, h?: string) => {
const {alerts} = getSettings()
const pref = alerts.find(spec({url}))
if (!pref) return true
if (!h) return pref.notify
if (pref.notify) return !pref.exceptions.includes(h)
if (!pref.notify) return pref.exceptions.includes(h)
}
export const deriveIsMuted = (url: string, h?: string) =>
derived(userSettingsValues, () => isMuted(url, h))