Switch wording to messaging from inbox

This commit is contained in:
Jon Staab
2025-11-20 15:12:16 -08:00
parent 1d272f8b37
commit 3a63894562
21 changed files with 149 additions and 169 deletions
+3 -3
View File
@@ -1,7 +1,8 @@
<script lang="ts">
import {sleep} from "@welshman/lib"
import {getTagValue, getAddress} from "@welshman/util"
import {getTagValue, getAddress, RelayMode} from "@welshman/util"
import {isRelayFeed, findFeed} from "@welshman/feeds"
import {getPubkeyRelays, pubkey} from "@welshman/app"
import Inbox from "@assets/icons/inbox.svg?dataurl"
import Bell from "@assets/icons/bell.svg?dataurl"
import AddCircle from "@assets/icons/add-circle.svg?dataurl"
@@ -15,7 +16,6 @@
alerts,
dmAlert,
deriveAlertStatus,
userInboxRelays,
getAlertFeed,
userSettingsValues,
} from "@app/core/state"
@@ -59,7 +59,7 @@
if ($dmAlert) {
deleteAlert($dmAlert)
} else {
if ($userInboxRelays.length === 0) {
if (getPubkeyRelays($pubkey!, RelayMode.Messaging).length === 0) {
return uncheckDmAlert("Please set up your messaging relays before enabling alerts.")
}
+16 -16
View File
@@ -28,8 +28,8 @@
tagPubkey,
sendWrapped,
mergeThunks,
loadInboxRelaySelections,
inboxRelaySelectionsByPubkey,
loadMessagingRelayList,
messagingRelayListsByPubkey,
} from "@welshman/app"
import Danger from "@assets/icons/danger-triangle.svg?dataurl"
import Icon from "@lib/components/Icon.svelte"
@@ -69,7 +69,7 @@
const chat = deriveChat(id)
const pubkeys = splitChatId(id)
const others = remove($pubkey!, pubkeys)
const missingInboxes = $derived(pubkeys.filter(pk => !$inboxRelaySelectionsByPubkey.has(pk)))
const missingRelayLists = $derived(pubkeys.filter(pk => !$messagingRelayListsByPubkey.has(pk)))
const showMembers = () =>
others.length === 1
@@ -151,7 +151,7 @@
let compose: ChatCompose | undefined = $state()
let parent: TrustedEvent | undefined = $state()
let chatCompose: HTMLElement | undefined = $state()
let dynamicPadding: HTMLElement | undefined = $state()
let dlists: HTMLElelist | undefined = $state()
const elements = $derived.by(() => {
const elements = []
@@ -185,7 +185,7 @@
onMount(() => {
for (const pubkey of others) {
loadInboxRelaySelections(pubkey, INDEXER_RELAYS, true)
loadMessagingRelayList(pubkey, INDEXER_RELAYS, true)
}
const observer = new ResizeObserver(() => {
@@ -239,12 +239,12 @@
</Button>
{/snippet}
{#snippet action()}
{#if remove($pubkey, missingInboxes).length > 0}
{@const count = remove($pubkey, missingInboxes).length}
{@const label = count > 1 ? "inboxes are" : "inbox is"}
{#if remove($pubkey, missingRelayLists).length > 0}
{@const count = remove($pubkey, missingRelayLists).length}
{@const label = count > 1 ? "lists are" : "list is"}
<div
class="row-2 badge badge-error badge-lg tooltip tooltip-left cursor-pointer"
data-tip="{count} {label} not configured.">
data-tip="{count} messaging {label} not configured.">
<Icon icon={Danger} />
{count}
</div>
@@ -254,30 +254,30 @@
<PageContent class="flex flex-col-reverse gap-2 pt-4">
<div bind:this={dynamicPadding}></div>
{#if missingInboxes.includes($pubkey!)}
{#if missingRelayLists.includes($pubkey!)}
<div class="py-12">
<div class="card2 col-2 m-auto max-w-md items-center text-center">
<p class="row-2 text-lg text-error">
<Icon icon={Danger} />
Your inbox is not configured.
Your messaging relays are not configured.
</p>
<p>
In order to deliver messages, {PLATFORM_NAME} needs to know where to send them. Please visit
your <Link class="link" href="/settings/relays">relay settings page</Link> to set up your inbox.
your <Link class="link" href="/settings/relays">relay settings page</Link> to receive messages.
</p>
</div>
</div>
{:else if missingInboxes.length > 0}
{:else if missingRelayLists.length > 0}
<div class="py-12">
<div class="card2 col-2 m-auto max-w-md items-center text-center">
<p class="row-2 text-lg text-error">
<Icon icon={Danger} />
{missingInboxes.length}
{missingInboxes.length > 1 ? "inboxes are" : "inbox is"} not configured.
{missingRelayLists.length} messaging
{missingRelayLists.length > 1 ? "lists are" : "list is"} not configured.
</p>
<p>
In order to deliver messages, {PLATFORM_NAME} needs to know where to send them. Please make
sure everyone in this conversation has set up their inbox relays.
sure everyone in this conversation has set up their messaging relays.
</p>
</div>
</div>
+2 -2
View File
@@ -3,7 +3,7 @@
import {page} from "$app/stores"
import {remove} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util"
import {pubkey, loadInboxRelaySelections} from "@welshman/app"
import {pubkey, loadMessagingRelayList} from "@welshman/app"
import {fade} from "@lib/transition"
import Link from "@lib/components/Link.svelte"
import ProfileName from "@app/components/ProfileName.svelte"
@@ -27,7 +27,7 @@
onMount(() => {
for (const pk of others) {
loadInboxRelaySelections(pk)
loadMessagingRelayList(pk)
}
})
</script>
+4 -3
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import {waitForThunkCompletion} from "@welshman/app"
import {RelayMode} from "@welshman/util"
import {waitForThunkCompletion, getPubkeyRelays, pubkey} from "@welshman/app"
import ChatSquare from "@assets/icons/chat-square.svg?dataurl"
import Check from "@assets/icons/check.svg?dataurl"
import Bell from "@assets/icons/bell.svg?dataurl"
@@ -11,7 +12,7 @@
import {setChecked} from "@app/util/notifications"
import {pushModal} from "@app/util/modal"
import {pushToast} from "@app/util/toast"
import {dmAlert, userInboxRelays} from "@app/core/state"
import {dmAlert} from "@app/core/state"
import {deleteAlert, createDmAlert} from "@app/core/commands"
const startChat = () => pushModal(ChatStart, {}, {replaceState: true})
@@ -22,7 +23,7 @@
}
const enableAlerts = async () => {
if ($userInboxRelays.length === 0) {
if (getPubkeyRelays($pubkey!, RelayMode.Messaging).length === 0) {
return pushToast({
theme: "error",
message: "Please set up your messaging relays before enabling alerts.",
+5 -9
View File
@@ -6,14 +6,10 @@
import {deriveEvents} from "@welshman/store"
import {formatTimestampRelative} from "@welshman/lib"
import {NOTE, ROOMS, COMMENT} from "@welshman/util"
import {repository, loadRelaySelections} from "@welshman/app"
import {repository, loadRelayList} from "@welshman/app"
import Button from "@lib/components/Button.svelte"
import ProfileSpaces from "@app/components/ProfileSpaces.svelte"
import {
deriveGroupSelections,
getSpaceUrlsFromGroupSelections,
MESSAGE_KINDS,
} from "@app/core/state"
import {deriveGroupList, getSpaceUrlsFromGroupLists, MESSAGE_KINDS} from "@app/core/state"
import {goToEvent} from "@app/util/routes"
import {pushModal} from "@app/util/modal"
@@ -25,8 +21,8 @@
const {pubkey, url}: Props = $props()
const filters: Filter[] = [{authors: [pubkey], limit: 1}]
const events = deriveEvents(repository, {filters})
const selections = deriveGroupSelections(pubkey)
const spaceUrls = $derived(getSpaceUrlsFromGroupSelections($selections))
const groupList = deriveGroupList(pubkey)
const spaceUrls = $derived(getSpaceUrlsFromGroupList($groupList))
const viewEvent = () => goToEvent($events[0]!)
@@ -34,7 +30,7 @@
onMount(async () => {
// Make sure we have their relay selections before we load their posts
await loadRelaySelections(pubkey)
await loadRelayList(pubkey)
// Load groups and at least one note, regardless of time frame
load({
+4 -2
View File
@@ -7,8 +7,9 @@
DELETE,
isReplaceable,
getAddress,
RelayMode,
} from "@welshman/util"
import {pubkey, publishThunk, repository} from "@welshman/app"
import {pubkey, publishThunk, repository, derivePubkeyRelays} from "@welshman/app"
import {preventDefault} from "@lib/html"
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
import AltArrowRight from "@assets/icons/alt-arrow-right.svg?dataurl"
@@ -19,12 +20,13 @@
import ModalFooter from "@lib/components/ModalFooter.svelte"
import {pushToast} from "@app/util/toast"
import {logout} from "@app/core/commands"
import {INDEXER_RELAYS, PLATFORM_NAME, userSpaceUrls, userWriteRelays} from "@app/core/state"
import {INDEXER_RELAYS, PLATFORM_NAME, userSpaceUrls} from "@app/core/state"
let progress: number | undefined = $state(undefined)
let confirmText = $state("")
const CONFIRM_TEXT = "permanently delete my nostr account"
const userWriteRelays = derivePubkeyRelays($pubkey!, RelayMode.Write)
const confirmOk = $derived(confirmText.toLowerCase().trim() === CONFIRM_TEXT)
const showProgress = $derived(progress !== undefined)
+1 -1
View File
@@ -32,7 +32,7 @@
}
success = true
pushToast({message: "Success! Please check your inbox and continue when you're ready."})
pushToast({message: "Success! Please check your messages and continue when you're ready."})
await logout()
} finally {
+3 -3
View File
@@ -8,7 +8,7 @@
import RelayIcon from "@app/components/RelayIcon.svelte"
import RelayName from "@app/components/RelayName.svelte"
import {makeSpacePath} from "@app/util/routes"
import {deriveGroupSelections, getSpaceUrlsFromGroupSelections} from "@app/core/state"
import {deriveGroupList, getSpaceUrlsFromGroupList} from "@app/core/state"
type Props = {
pubkey: string
@@ -16,8 +16,8 @@
const {pubkey}: Props = $props()
const selections = deriveGroupSelections(pubkey)
const spaceUrls = $derived(getSpaceUrlsFromGroupSelections($selections))
const groupList = deriveGroupList(pubkey)
const spaceUrls = $derived(getSpaceUrlsFromGroupList($groupList))
const back = () => history.back()
</script>
+7 -3
View File
@@ -2,7 +2,7 @@
import {uniqBy, prop, ifLet} from "@welshman/lib"
import type {RelayProfile} from "@welshman/util"
import {displayRelayUrl, ManagementMethod} from "@welshman/util"
import {manageRelay, relays, fetchRelayProfileDirectly} from "@welshman/app"
import {manageRelay, relays, fetchRelayDirectly} from "@welshman/app"
import StickerSmileSquare from "@assets/icons/sticker-smile-square.svg?dataurl"
import SettingsMinimalistic from "@assets/icons/settings-minimalistic.svg?dataurl"
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
@@ -72,8 +72,12 @@
}
// Force-reload the relay
ifLet(await fetchRelayProfileDirectly(url), profile => {
relays.update($relays => uniqBy(prop("url"), [{...profile, url}, ...$relays]))
ifLet(await fetchRelayDirectly(url), relay => {
relaysByUrl.update($relaysByUrl => {
$relaysByUrl.set(url, relay)
return new Map($relaysByUrl)
})
})
pushToast({message: "Your changes have been saved!"})
+15 -15
View File
@@ -31,7 +31,7 @@ import {
DELETE,
REPORT,
PROFILE,
INBOX_RELAYS,
MESSAGING_RELAYS,
RELAYS,
FOLLOWS,
REACTION,
@@ -82,8 +82,8 @@ import {
profilesByPubkey,
tagEvent,
tagEventForReaction,
userRelaySelections,
userInboxRelaySelections,
userRelayList,
userMessagingRelayList,
nip44EncryptToSelf,
dropSession,
tagEventForComment,
@@ -106,8 +106,8 @@ import {
userSpaceUrls,
userSettingsValues,
getSetting,
userInboxRelays,
userGroupSelections,
userMessagingRelays,
userGroupList,
shouldIgnoreError,
} from "@app/core/state"
import {loadAlertStatuses} from "@app/core/requests"
@@ -164,7 +164,7 @@ export const logout = async () => {
export const broadcastUserData = async (relays: string[]) => {
const authors = [pubkey.get()!]
const kinds = [RELAYS, INBOX_RELAYS, FOLLOWS, PROFILE]
const kinds = [RELAYS, MESSAGING_RELAYS, FOLLOWS, PROFILE]
const events = repository.query([{kinds, authors}])
for (const event of events) {
@@ -177,7 +177,7 @@ export const broadcastUserData = async (relays: string[]) => {
// List updates
export const addSpaceMembership = async (url: string) => {
const list = get(userGroupSelections) || makeList({kind: ROOMS})
const list = get(userGroupList) || makeList({kind: ROOMS})
const event = await addToListPublicly(list, ["r", url]).reconcile(nip44EncryptToSelf)
const relays = uniq([...Router.get().FromUser().getUrls(), ...getRelayTagValues(event.tags)])
@@ -185,7 +185,7 @@ export const addSpaceMembership = async (url: string) => {
}
export const removeSpaceMembership = async (url: string) => {
const list = get(userGroupSelections) || makeList({kind: ROOMS})
const list = get(userGroupList) || makeList({kind: ROOMS})
const pred = (t: string[]) => t[t[0] === "r" ? 1 : 2] === url
const event = await removeFromListByPredicate(list, pred).reconcile(nip44EncryptToSelf)
const relays = uniq([url, ...Router.get().FromUser().getUrls(), ...getRelayTagValues(event.tags)])
@@ -194,7 +194,7 @@ export const removeSpaceMembership = async (url: string) => {
}
export const addRoomMembership = async (url: string, h: string) => {
const list = get(userGroupSelections) || makeList({kind: ROOMS})
const list = get(userGroupList) || makeList({kind: ROOMS})
const newTags = [
["r", url],
["group", h, url],
@@ -206,7 +206,7 @@ export const addRoomMembership = async (url: string, h: string) => {
}
export const removeRoomMembership = async (url: string, h: string) => {
const list = get(userGroupSelections) || makeList({kind: ROOMS})
const list = get(userGroupList) || makeList({kind: ROOMS})
const pred = (t: string[]) => equals(["group", h, url], t.slice(0, 3))
const event = await removeFromListByPredicate(list, pred).reconcile(nip44EncryptToSelf)
const relays = uniq([url, ...Router.get().FromUser().getUrls(), ...getRelayTagValues(event.tags)])
@@ -215,7 +215,7 @@ export const removeRoomMembership = async (url: string, h: string) => {
}
export const setRelayPolicy = (url: string, read: boolean, write: boolean) => {
const list = get(userRelaySelections) || makeList({kind: RELAYS})
const list = get(userRelayList) || makeList({kind: RELAYS})
const tags = getRelayTags(getListTags(list)).filter(t => normalizeRelayUrl(t[1]) !== url)
if (read && write) {
@@ -232,10 +232,10 @@ export const setRelayPolicy = (url: string, read: boolean, write: boolean) => {
})
}
export const setInboxRelayPolicy = (url: string, enabled: boolean) => {
const list = get(userInboxRelaySelections) || makeList({kind: INBOX_RELAYS})
export const setMessagingRelayPolicy = (url: string, enabled: boolean) => {
const list = get(userMessagingRelayList) || makeList({kind: MESSAGING_RELAYS})
// Only update inbox policies if they already exist or we're adding them
// Only update messaging policies if they already exist or we're adding them
if (enabled || getRelaysFromList(list).includes(url)) {
const tags = getRelayTags(getListTags(list)).filter(t => normalizeRelayUrl(t[1]) !== url)
@@ -542,7 +542,7 @@ export const createDmAlert = async () => {
description: `for direct messages.`,
feed: makeIntersectionFeed(
feedFromFilters([{kinds: [WRAP], "#p": [pubkey.get()!]}]),
makeRelayFeed(...get(userInboxRelays)),
makeRelayFeed(...get(userMessagingRelays)),
),
})
}
+22 -37
View File
@@ -122,8 +122,8 @@ import {
appContext,
getThunkError,
publishThunk,
userRelaySelections,
userInboxRelaySelections,
userRelayList,
userMessagingRelayList,
deriveRelay,
makeUserData,
makeUserLoader,
@@ -390,18 +390,6 @@ 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 = {
@@ -610,29 +598,29 @@ export const displayRoom = (url: string, h: string) =>
export const roomComparator = (url: string) => (h: string) => displayRoom(url, h).toLowerCase()
// User space/room selections
// User space/room lists
export const groupSelections = deriveEventsMapped<PublishedList>(repository, {
export const groupLists = deriveEventsMapped<PublishedList>(repository, {
filters: [{kinds: [ROOMS]}],
itemToEvent: item => item.event,
eventToItem: (event: TrustedEvent) => readList(asDecryptedEvent(event)),
})
export const {
indexStore: groupSelectionsByPubkey,
deriveItem: deriveGroupSelections,
loadItem: loadGroupSelections,
indexStore: groupListsByPubkey,
deriveItem: deriveGroupList,
loadItem: loadGroupList,
} = collection({
name: "groupSelections",
store: groupSelections,
name: "groupLists",
store: groupLists,
getKey: list => list.event.pubkey,
load: makeOutboxLoader(ROOMS),
})
export const groupSelectionsPubkeysByUrl = derived(groupSelections, $groupSelections => {
export const groupListsPubkeysByUrl = derived(groupLists, $groupLists => {
const result = new Map<string, Set<string>>()
for (const list of $groupSelections) {
for (const list of $groupLists) {
const tags = getListTags(list)
for (const url of getRelayTagValues(tags)) {
@@ -651,8 +639,8 @@ export const groupSelectionsPubkeysByUrl = derived(groupSelections, $groupSelect
return result
})
export const getSpaceUrlsFromGroupSelections = ($groupSelections: List | undefined) => {
const tags = getListTags($groupSelections)
export const getSpaceUrlsFromGroupList = ($groupLists: List | undefined) => {
const tags = getListTags($groupLists)
const urls = getRelayTagValues(tags)
for (const tag of getGroupTags(tags)) {
@@ -666,13 +654,10 @@ export const getSpaceUrlsFromGroupSelections = ($groupSelections: List | undefin
return uniq(urls.map(normalizeRelayUrl))
}
export const getSpaceRoomsFromGroupSelections = (
url: string,
$groupSelections: List | undefined,
) => {
export const getSpaceRoomsFromGroupList = (url: string, $groupList: List | undefined) => {
const rooms: string[] = []
for (const [_, h, relay] of getGroupTags(getListTags($groupSelections))) {
for (const [_, h, relay] of getGroupTags(getListTags($groupList))) {
if (url === relay) {
rooms.push(h)
}
@@ -681,20 +666,20 @@ export const getSpaceRoomsFromGroupSelections = (
return sortBy(roomComparator(url), rooms)
}
export const userGroupSelections = makeUserData({
mapStore: groupSelectionsByPubkey,
loadItem: loadGroupSelections,
export const userGroupList = makeUserData({
mapStore: groupListsByPubkey,
loadItem: loadGroupList,
})
export const loadUserGroupSelections = makeUserLoader(loadGroupSelections)
export const loadUserGroupList = makeUserLoader(loadGroupList)
export const userSpaceUrls = derived(userGroupSelections, getSpaceUrlsFromGroupSelections)
export const userSpaceUrls = derived(userGroupList, getSpaceUrlsFromGroupLists)
export const deriveUserRooms = (url: string) =>
derived([userGroupSelections, roomsById], ([$userGroupSelections, $roomsById]) => {
derived([userGroupList, roomsById], ([$userGroupList, $roomsById]) => {
const rooms: string[] = []
for (const h of getSpaceRoomsFromGroupSelections(url, $userGroupSelections)) {
for (const h of getSpaceRoomsFromGroupList(url, $userGroupList)) {
if ($roomsById.has(makeRoomId(url, h))) {
rooms.push(h)
}
+25 -25
View File
@@ -25,10 +25,10 @@ import {
pubkey,
loadRelay,
userFollows,
userRelaySelections,
userInboxRelaySelections,
loadRelaySelections,
loadInboxRelaySelections,
userRelayList,
userMessagingRelayList,
loadRelayList,
loadMessagingRelayList,
loadBlossomServers,
loadFollows,
loadMutes,
@@ -43,14 +43,14 @@ import {
CONTENT_KINDS,
INDEXER_RELAYS,
loadSettings,
loadGroupSelections,
loadGroupList,
userSpaceUrls,
userGroupSelections,
userGroupList,
bootstrapPubkeys,
decodeRelay,
getUrlsForEvent,
getSpaceUrlsFromGroupSelections,
getSpaceRoomsFromGroupSelections,
getSpaceUrlsFromGroupList,
getSpaceRoomsFromGroupList,
makeCommentFilter,
} from "@app/core/state"
import {loadAlerts, loadAlertStatuses} from "@app/core/requests"
@@ -173,20 +173,20 @@ const syncUserRoomMembership = (url: string, h: string) => {
const syncUserData = () => {
const unsubscribersByKey = new Map<string, Unsubscriber>()
const unsubscribeGroupSelections = userGroupSelections.subscribe($l => {
const unsubscribeGroupList = userGroupList.subscribe($l => {
const $pubkey = pubkey.get()
if ($pubkey) {
const keys = new Set<string>()
for (const url of getSpaceUrlsFromGroupSelections($l)) {
for (const url of getSpaceUrlsFromGroupList($l)) {
if (!unsubscribersByKey.has(url)) {
unsubscribersByKey.set(url, syncUserSpaceMembership(url))
}
keys.add(url)
for (const h of getSpaceRoomsFromGroupSelections(url, $l)) {
for (const h of getSpaceRoomsFromGroupList(url, $l)) {
const key = `${url}'${h}`
if (!unsubscribersByKey.has(key)) {
@@ -206,7 +206,7 @@ const syncUserData = () => {
}
})
const unsubscribeSelections = userRelaySelections.subscribe($l => {
const unsubscribeList = userRelayList.subscribe($l => {
const $pubkey = pubkey.get()
if ($pubkey) {
@@ -214,7 +214,7 @@ const syncUserData = () => {
loadAlertStatuses($pubkey)
loadBlossomServers($pubkey)
loadFollows($pubkey)
loadGroupSelections($pubkey)
loadGroupList($pubkey)
loadMutes($pubkey)
loadProfile($pubkey)
loadSettings($pubkey)
@@ -228,8 +228,8 @@ const syncUserData = () => {
await Promise.all(
pubkeys.map(async pk => {
await loadRelaySelections(pk)
await loadGroupSelections(pk)
await loadRelayList(pk)
await loadGroupList(pk)
await loadProfile(pk)
await loadFollows(pk)
await loadMutes(pk)
@@ -240,14 +240,14 @@ const syncUserData = () => {
const unsubscribePubkey = pubkey.subscribe($pubkey => {
if ($pubkey) {
loadRelaySelections($pubkey)
loadRelayList($pubkey)
}
})
return () => {
unsubscribersByKey.forEach(call)
unsubscribeGroupSelections()
unsubscribeSelections()
unsubscribeGroupList()
unsubscribeList()
unsubscribeFollows()
unsubscribePubkey()
}
@@ -386,10 +386,10 @@ const syncDMs = () => {
unsubscribeAll()
}
// If we have a pubkey, refresh our user's relay selections then sync our subscriptions
// If we have a pubkey, refresh our user's relay list then sync our subscriptions
if ($pubkey && $shouldUnwrap) {
loadRelaySelections($pubkey)
.then(() => loadInboxRelaySelections($pubkey))
loadRelayList($pubkey)
.then(() => loadMessagingRelayList($pubkey))
.then($l => subscribeAll($pubkey, getRelayTagValues(getListTags($l))))
}
@@ -397,20 +397,20 @@ const syncDMs = () => {
},
)
// When user inbox relays change, update synchronization
const unsubscribeSelections = userInboxRelaySelections.subscribe($userInboxRelaySelections => {
// When user messaging relays change, update synchronization
const unsubscribeList = userMessagingRelayList.subscribe($userMessagingRelayList => {
const $pubkey = pubkey.get()
const $shouldUnwrap = shouldUnwrap.get()
if ($pubkey && $shouldUnwrap) {
subscribeAll($pubkey, getRelayTagValues(getListTags($userInboxRelaySelections)))
subscribeAll($pubkey, getRelayTagValues(getListTags($userMessagingRelayList)))
}
})
return () => {
unsubscribeAll()
unsubscribePubkey()
unsubscribeSelections()
unsubscribeList()
}
}
+7 -15
View File
@@ -20,9 +20,9 @@ import {
getUrlsForEvent,
repositoryStore,
userSettingsValues,
userGroupSelections,
getSpaceUrlsFromGroupSelections,
getSpaceRoomsFromGroupSelections,
userGroupList,
getSpaceUrlsFromGroupList,
getSpaceRoomsFromGroupList,
} from "@app/core/state"
import {kv} from "@app/core/storage"
@@ -44,19 +44,11 @@ export const notifications = derived(
throttled(
1000,
derived(
[pubkey, checked, chats, userGroupSelections, repositoryStore, getUrlsForEvent, relaysByUrl],
[pubkey, checked, chats, userGroupList, repositoryStore, getUrlsForEvent, relaysByUrl],
identity,
),
),
([
$pubkey,
$checked,
$chats,
$userGroupSelections,
$repository,
$getUrlsForEvent,
$relaysByUrl,
]) => {
([$pubkey, $checked, $chats, $userGroupList, $repository, $getUrlsForEvent, $relaysByUrl]) => {
const hasNotification = (path: string, latestEvent: TrustedEvent | undefined) => {
if (!latestEvent || latestEvent.pubkey === $pubkey) {
return false
@@ -95,7 +87,7 @@ export const notifications = derived(
const allMessages = $repository.query([{kinds: [MESSAGE, THREAD, ZAP_GOAL, EVENT_TIME]}])
for (const url of getSpaceUrlsFromGroupSelections($userGroupSelections)) {
for (const url of getSpaceUrlsFromGroupList($userGroupList)) {
const spacePath = makeSpacePath(url)
const spacePathMobile = spacePath + ":mobile"
const goalPath = makeGoalPath(url)
@@ -171,7 +163,7 @@ export const notifications = derived(
}
if (hasNip29($relaysByUrl.get(url))) {
for (const h of getSpaceRoomsFromGroupSelections(url, $userGroupSelections)) {
for (const h of getSpaceRoomsFromGroupList(url, $userGroupList)) {
const roomPath = makeRoomPath(url, h)
const latestEvent = messages.find(e => e.tags.some(spec(["h", h])))
+2 -2
View File
@@ -12,7 +12,7 @@ import {
DIRECT_MESSAGE,
EVENT_TIME,
FOLLOWS,
INBOX_RELAYS,
MESSAGING_RELAYS,
MESSAGE,
MUTES,
PROFILE,
@@ -54,7 +54,7 @@ import {isMobile} from "@lib/html"
import type {IDBTable} from "@lib/indexeddb"
const kinds = {
meta: [PROFILE, FOLLOWS, MUTES, RELAYS, BLOSSOM_SERVERS, INBOX_RELAYS, APP_DATA, ROOMS],
meta: [PROFILE, FOLLOWS, MUTES, RELAYS, BLOSSOM_SERVERS, MESSAGING_RELAYS, APP_DATA, ROOMS],
alert: [ALERT_STATUS, ALERT_EMAIL, ALERT_WEB, ALERT_IOS, ALERT_ANDROID],
space: [RELAY_ADD_MEMBER, RELAY_REMOVE_MEMBER, RELAY_MEMBERS, RELAY_JOIN, RELAY_LEAVE],
room: [
+7 -7
View File
@@ -25,9 +25,9 @@
import SpaceCheck from "@app/components/SpaceCheck.svelte"
import {
bootstrapPubkeys,
loadGroupSelections,
getSpaceUrlsFromGroupSelections,
groupSelectionsPubkeysByUrl,
loadGroupList,
getSpaceUrlsFromGroupList,
groupListsPubkeysByUrl,
parseInviteLink,
} from "@app/core/state"
import {pushModal} from "@app/util/modal"
@@ -50,8 +50,8 @@
relays: Router.get().Index().getUrls(),
}),
...$bootstrapPubkeys.map(async pubkey => {
const list = await loadGroupSelections(pubkey)
const urls = getSpaceUrlsFromGroupSelections(list)
const list = await loadGroupList(pubkey)
const urls = getSpaceUrlsFromGroupList(list)
await Promise.all(urls.map(url => loadRelay(url)))
}),
@@ -59,13 +59,13 @@
const relaySearch = $derived(
createSearch(
$relays.filter(r => $groupSelectionsPubkeysByUrl.has(r.url) && r.url !== inviteData?.url),
$relays.filter(r => $groupListsPubkeysByUrl.has(r.url) && r.url !== inviteData?.url),
{
getValue: (relay: RelayProfile) => relay.url,
sortFn: ({score, item}) => {
if (score && score > 0.1) return -score!
const wotScore = $groupSelectionsPubkeysByUrl.get(item.url)!.size
const wotScore = $groupListsPubkeysByUrl.get(item.url)!.size
return score ? dec(score) * wotScore : -wotScore
},
+5 -5
View File
@@ -9,7 +9,7 @@
BLOSSOM_SERVERS,
} from "@welshman/util"
import {Router} from "@welshman/router"
import {userMutes, tagPubkey, publishThunk, userBlossomServers} from "@welshman/app"
import {userMuteList, tagPubkey, publishThunk, userBlossomServerList} from "@welshman/app"
import {preventDefault} from "@lib/html"
import Field from "@lib/components/Field.svelte"
import FieldInline from "@lib/components/FieldInline.svelte"
@@ -22,8 +22,8 @@
const reset = () => {
settings = {...$userSettingsValues}
mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
blossomServers = getTagValues("server", getListTags($userBlossomServers))
mutedPubkeys = getPubkeyTagValues(getListTags($userMuteList))
blossomServers = getTagValues("server", getListTags($userBlossomServerList))
}
const onsubmit = preventDefault(async () => {
@@ -43,8 +43,8 @@
})
let settings = $state({...$userSettingsValues})
let mutedPubkeys = $state(getPubkeyTagValues(getListTags($userMutes)))
let blossomServers = $state(getTagValues("server", getListTags($userBlossomServers)))
let mutedPubkeys = $state(getPubkeyTagValues(getListTags($userMuteList)))
let blossomServers = $state(getTagValues("server", getListTags($userBlossomServerList)))
</script>
<form class="content column gap-4" {onsubmit}>
+11 -11
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import {onMount} from "svelte"
import {pubkey, relaySelections, inboxRelaySelections, derivePubkeyRelays} from "@welshman/app"
import {pubkey, getRelayLists, getMessagingRelayLists, derivePubkeyRelays} from "@welshman/app"
import {RelayMode} from "@welshman/util"
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
@@ -9,7 +9,7 @@
import RelayAdd from "@app/components/RelayAdd.svelte"
import {pushModal} from "@app/util/modal"
import {discoverRelays} from "@app/core/requests"
import {setRelayPolicy, setInboxRelayPolicy} from "@app/core/commands"
import {setRelayPolicy, setMessagingRelayPolicy} from "@app/core/commands"
import Globus from "@assets/icons/globus.svg?dataurl"
import Inbox from "@assets/icons/inbox.svg?dataurl"
import Mailbox from "@assets/icons/mailbox.svg?dataurl"
@@ -18,7 +18,7 @@
const readRelayUrls = derivePubkeyRelays($pubkey!, RelayMode.Read)
const writeRelayUrls = derivePubkeyRelays($pubkey!, RelayMode.Write)
const inboxRelayUrls = derivePubkeyRelays($pubkey!, RelayMode.Inbox)
const messagingRelayUrls = derivePubkeyRelays($pubkey!, RelayMode.Messaging)
const addReadRelay = () =>
pushModal(RelayAdd, {
@@ -32,20 +32,20 @@
addRelay: (url: string) => setRelayPolicy(url, $readRelayUrls.includes(url), true),
})
const addInboxRelay = () =>
const addMessagingRelay = () =>
pushModal(RelayAdd, {
relays: inboxRelayUrls,
addRelay: (url: string) => setInboxRelayPolicy(url, true),
relays: messagingRelayUrls,
addRelay: (url: string) => setMessagingRelayPolicy(url, true),
})
const removeReadRelay = (url: string) => setRelayPolicy(url, false, $writeRelayUrls.includes(url))
const removeWriteRelay = (url: string) => setRelayPolicy(url, $readRelayUrls.includes(url), false)
const removeInboxRelay = (url: string) => setInboxRelayPolicy(url, false)
const removeMessagingRelay = (url: string) => setMessagingRelayPolicy(url, false)
onMount(() => {
discoverRelays([...$relaySelections, ...$inboxRelaySelections])
discoverRelays([...getRelayLists(), ...getMessagingRelayLists()])
})
</script>
@@ -130,19 +130,19 @@
</p>
{/snippet}
<div class="column gap-2">
{#each $inboxRelayUrls.sort() as url (url)}
{#each $messagingRelayUrls.sort() as url (url)}
<RelayItem {url}>
<Button
class="tooltip flex items-center"
data-tip="Stop using this relay"
onclick={() => removeInboxRelay(url)}>
onclick={() => removeMessagingRelay(url)}>
<Icon icon={CloseCircle} />
</Button>
</RelayItem>
{:else}
<p class="text-center text-sm">No relays found</p>
{/each}
<Button class="btn btn-primary mt-2" onclick={addInboxRelay}>
<Button class="btn btn-primary mt-2" onclick={addMessagingRelay}>
<Icon icon={AddCircle} />
Add Relay
</Button>
+2 -2
View File
@@ -8,7 +8,7 @@
import PageContent from "@lib/components/PageContent.svelte"
import MenuSpacesItem from "@app/components/MenuSpacesItem.svelte"
import SpaceAdd from "@app/components/SpaceAdd.svelte"
import {userSpaceUrls, loadUserGroupSelections, PLATFORM_RELAYS} from "@app/core/state"
import {userSpaceUrls, loadUserGroupList, PLATFORM_RELAYS} from "@app/core/state"
import {pushModal} from "@app/util/modal"
const addSpace = () => pushModal(SpaceAdd)
@@ -37,7 +37,7 @@
{#each PLATFORM_RELAYS as url (url)}
<MenuSpacesItem {url} />
{:else}
{#await loadUserGroupSelections()}
{#await loadUserGroupList()}
<div class="flex justify-center items-center py-20">
<span class="loading loading-spinner mr-3"></span>
Loading your spaces...
@@ -6,7 +6,7 @@
import {COMMENT, getTagValue} from "@welshman/util"
import {request} from "@welshman/net"
import {repository} from "@welshman/app"
import {deriveEvents} from "@welshman/store"
import {deriveEventsById, deriveEventsDesc} from "@welshman/store"
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
import SortVertical from "@assets/icons/sort-vertical.svg?dataurl"
import Reply from "@assets/icons/reply-2.svg?dataurl"
@@ -30,7 +30,7 @@
const url = decodeRelay(relay)
const event = deriveEvent(id)
const filters = [{kinds: [COMMENT], "#E": [id]}]
const replies = deriveEvents(repository, {filters})
const replies = deriveEventsDesc(deriveEventsById({filters, repository}))
const back = () => history.back()
@@ -6,7 +6,7 @@
import {COMMENT, getTagValue} from "@welshman/util"
import {repository} from "@welshman/app"
import {request} from "@welshman/net"
import {deriveEvents} from "@welshman/store"
import {deriveEventsById, deriveEventsDesc} from "@welshman/store"
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
import SortVertical from "@assets/icons/sort-vertical.svg?dataurl"
import Reply from "@assets/icons/reply-2.svg?dataurl"
@@ -29,7 +29,7 @@
const url = decodeRelay(relay)
const event = deriveEvent(id)
const filters = [{kinds: [COMMENT], "#E": [id]}]
const replies = deriveEvents(repository, {filters})
const replies = deriveEventsDesc(deriveEventsById({repository, filters}))
const summary = getTagValue("summary", $event.tags)
const back = () => history.back()
@@ -98,7 +98,7 @@
</Button>
</div>
{/if}
{#each sortBy(e => e.created_at, $replies).slice(0, showAll ? undefined : 4) as reply (reply.id)}
{#each $replies.slice(0, showAll ? undefined : 4) as reply (reply.id)}
<NoteCard event={reply} {url} class="card2 bg-alt z-feature w-full">
<div class="col-3 ml-12">
<Content showEntire event={reply} {url} />
@@ -6,7 +6,7 @@
import {COMMENT, getTagValue} from "@welshman/util"
import {repository} from "@welshman/app"
import {request} from "@welshman/net"
import {deriveEvents} from "@welshman/store"
import {deriveEventsById, deriveEventsDesc} from "@welshman/store"
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
import SortVertical from "@assets/icons/sort-vertical.svg?dataurl"
import Reply from "@assets/icons/reply-2.svg?dataurl"
@@ -28,7 +28,7 @@
const url = decodeRelay(relay)
const event = deriveEvent(id)
const filters = [{kinds: [COMMENT], "#E": [id]}]
const replies = deriveEvents(repository, {filters})
const replies = deriveEventsDesc(deriveEventsById({filters, repository}))
const back = () => history.back()
@@ -95,7 +95,7 @@
</Button>
</div>
{/if}
{#each sortBy(e => e.created_at, $replies).slice(0, showAll ? undefined : 4) as reply (reply.id)}
{#each $replies.slice(0, showAll ? undefined : 4) as reply (reply.id)}
<NoteCard event={reply} {url} class="card2 bg-alt z-feature w-full">
<div class="col-3 ml-12">
<Content showEntire event={reply} {url} />