- {$aliasDisplay}
+ {$display}
diff --git a/src/app/components/ProfileEditForm.svelte b/src/app/components/ProfileEditForm.svelte
index ff75253..13288e2 100644
--- a/src/app/components/ProfileEditForm.svelte
+++ b/src/app/components/ProfileEditForm.svelte
@@ -91,8 +91,8 @@
{/snippet}
{#snippet info()}
- If enabled, changes will be published to the broader nostr network in addition to
- spaces you are a member of.
+ If enabled, changes will be published to the broader nostr network in addition to spaces you
+ are a member of.
{/snippet}
diff --git a/src/app/components/ProfileInfo.svelte b/src/app/components/ProfileInfo.svelte
index 0fca5f7..904784a 100644
--- a/src/app/components/ProfileInfo.svelte
+++ b/src/app/components/ProfileInfo.svelte
@@ -1,6 +1,6 @@
-{#if $alias?.profile}
-
+{#if $profile}
+
{/if}
diff --git a/src/app/state.ts b/src/app/state.ts
index 32a3397..a559aeb 100644
--- a/src/app/state.ts
+++ b/src/app/state.ts
@@ -1,5 +1,5 @@
import twColors from "tailwindcss/colors"
-import {get, derived, writable} from "svelte/store"
+import {get, derived, readable, writable} from "svelte/store"
import * as nip19 from "nostr-tools/nip19"
import {
remove,
@@ -16,6 +16,7 @@ import {
addToMapKey,
identity,
always,
+ omit,
} from "@welshman/lib"
import {load} from "@welshman/net"
import {
@@ -31,7 +32,6 @@ import {
GROUPS,
THREAD,
COMMENT,
- PROFILE,
getGroupTags,
getRelayTagValues,
getPubkeyTagValues,
@@ -44,7 +44,6 @@ import {
normalizeRelayUrl,
displayPubkey,
} from "@welshman/util"
-import {LOCAL_RELAY_URL} from "@welshman/relay"
import type {TrustedEvent, Profile, SignedEvent, PublishedList, List, Filter} from "@welshman/util"
import {Nip59, decrypt} from "@welshman/signer"
import {
@@ -82,6 +81,8 @@ export const GENERAL = "_"
export const PROTECTED = ["-"]
+export const ALIAS = 11000
+
export const ALERT = 32830
export const ALERT_STATUS = 32831
@@ -401,7 +402,7 @@ export const loadAliasByKey = makeCachedLoader({
return load({
relays: [url],
- filters: [{kinds: [PROFILE], authors: [pubkey]}],
+ filters: [{kinds: [ALIAS], authors: [pubkey]}],
onEvent: (event: TrustedEvent) => {
const profile = readProfile(event)
@@ -416,50 +417,23 @@ export const loadAliasByKey = makeCachedLoader({
})
export const deriveAlias = (pubkey: string, url?: string) => {
- const membershipUrls = getMembershipUrls(userMembership.get())
+ if (!url) return readable(undefined)
- // Attempt to load all relevant aliases
- for (const $url of [url, ...membershipUrls]) {
- if ($url) {
- const key = encodeAliasKey(pubkey, $url)
+ const key = encodeAliasKey(pubkey, url)
- loadAliasByKey(key)
- }
- }
+ loadAliasByKey(key)
- return derived([aliasesByKey, deriveProfile(pubkey)], ([$aliasesByKey, $profile]) => {
- // Try to find an alias for the url we were asked about
- if (url) {
- const alias = $aliasesByKey.get(encodeAliasKey(pubkey, url))
-
- if (alias) {
- return alias
- }
- }
-
- // Fall back to global profiles
- if ($profile) {
- return {
- pubkey,
- url: LOCAL_RELAY_URL,
- profile: $profile,
- }
- }
-
- // Fall back to other aliases we know about
- for (const $url of membershipUrls) {
- const alias = $aliasesByKey.get(encodeAliasKey(pubkey, $url))
-
- if (alias) {
- return alias
- }
- }
- })
+ return derived(aliasesByKey, $aliasesByKey => $aliasesByKey.get(key))
}
+export const deriveAliasedProfile = (pubkey: string, url?: string) =>
+ derived([deriveProfile(pubkey), deriveAlias(pubkey, url)], ([$profile, $alias]) =>
+ omit(["event"], {...$profile, ...$alias}),
+ )
+
export const deriveAliasDisplay = (pubkey: string, url?: string) =>
- derived(deriveAlias(pubkey, url), $alias =>
- displayProfile($alias?.profile, displayPubkey(pubkey)),
+ derived(deriveAliasedProfile(pubkey, url), $profile =>
+ displayProfile($profile, displayPubkey(pubkey)),
)
// Membership
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index df6e242..3918556 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -9,7 +9,7 @@
import {bytesToHex, hexToBytes} from "@noble/hashes/utils"
import {identity, memoize, sleep, defer, ago, WEEK, TaskQueue} from "@welshman/lib"
import type {TrustedEvent, StampedEvent} from "@welshman/util"
- import {WRAP, PROFILE, getTag} from "@welshman/util"
+ import {WRAP} from "@welshman/util"
import {Nip46Broker, makeSecret} from "@welshman/signer"
import type {Socket} from "@welshman/net"
import {request, defaultSocketPolicies, makeSocketPolicyAuth} from "@welshman/net"
diff --git a/src/routes/settings/profile/+page.svelte b/src/routes/settings/profile/+page.svelte
index ca293ce..2553635 100644
--- a/src/routes/settings/profile/+page.svelte
+++ b/src/routes/settings/profile/+page.svelte
@@ -2,7 +2,7 @@
import * as nip19 from "nostr-tools/nip19"
import {hexToBytes} from "@noble/hashes/utils"
import {displayPubkey, displayProfile} from "@welshman/util"
- import {pubkey, session, displayNip05} from "@welshman/app"
+ import {pubkey, session, displayNip05, deriveProfile} from "@welshman/app"
import {slideAndFade} from "@lib/transition"
import Icon from "@lib/components/Icon.svelte"
import FieldInline from "@lib/components/FieldInline.svelte"
@@ -13,11 +13,11 @@
import ProfileDelete from "@app/components/ProfileDelete.svelte"
import InfoKeys from "@app/components/InfoKeys.svelte"
import Alerts from "@app/components/Alerts.svelte"
- import {PLATFORM_NAME, deriveAlias} from "@app/state"
+ import {PLATFORM_NAME} from "@app/state"
import {pushModal} from "@app/modal"
import {clip} from "@app/toast"
- const alias = deriveAlias($pubkey!)
+ const profile = deriveProfile($pubkey!)
const pubkeyDisplay = displayPubkey($pubkey!)
@@ -39,16 +39,16 @@
- {displayProfile($alias?.profile, pubkeyDisplay)}
+ {displayProfile($profile, pubkeyDisplay)}
- {$alias?.profile?.nip05 ? displayNip05($alias?.profile.nip05) : pubkeyDisplay}
+ {$profile?.nip05 ? displayNip05($profile.nip05) : pubkeyDisplay}
@@ -56,8 +56,8 @@
- {#key $alias?.profile?.about}
-
+ {#key $profile?.about}
+
{/key}