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