From f2e710c842dc00144347b835be79643061dcb875 Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Mon, 10 Apr 2023 09:01:51 -0500 Subject: [PATCH] Fix a few small bugs --- src/agent/relays.ts | 8 ++++++-- src/partials/MediaSet.svelte | 2 +- src/util/html.ts | 3 ++- src/util/nostr.ts | 2 +- src/views/notes/Note.svelte | 20 ++++++++++++++++---- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/agent/relays.ts b/src/agent/relays.ts index 6450dfa1..c48f6734 100644 --- a/src/agent/relays.ts +++ b/src/agent/relays.ts @@ -40,7 +40,7 @@ export const initializeRelayList = async () => { const url = import.meta.env.VITE_DUFFLEPUD_URL + "/relay" const json = await fetchJson(url) - await relays.bulkPatch(map(objOf("url"), json.relays.filter(isRelay))) + await relays.bulkPatch(json.relays.filter(isRelay).map(objOf("url"))) } catch (e) { warn("Failed to fetch relays list", e) } @@ -88,7 +88,11 @@ export const getAllPubkeyWriteRelays = pubkeys => getAllPubkeyRelays(pubkeys, "w // Current user -export const getUserRelays = () => user.getRelays().map(assoc("score", 1)) +export const getUserRelays = () => + user + .getRelays() + .filter(({url}) => isRelay(url)) + .map(assoc("score", 1)) export const getUserReadRelays = () => getUserRelays() diff --git a/src/partials/MediaSet.svelte b/src/partials/MediaSet.svelte index 3d9857ec..e349d2bb 100644 --- a/src/partials/MediaSet.svelte +++ b/src/partials/MediaSet.svelte @@ -32,7 +32,7 @@
{#if annotated.length > 1} -

+

Show {annotated.length} link previews

{/if} diff --git a/src/util/html.ts b/src/util/html.ts index ae7b88da..32fb82d3 100644 --- a/src/util/html.ts +++ b/src/util/html.ts @@ -119,6 +119,7 @@ export const parseContent = content => { } for (; i < text.length; ) { + const prev = last(result) const tail = text.slice(i) const newLine = tail.match(/^\n+/) @@ -162,7 +163,7 @@ export const parseContent = content => { ) // Skip url if it's just the end of a filepath - if (urlMatch && !last(result)?.value.endsWith("/")) { + if (urlMatch && (prev?.type !== "text" || !prev.value.endsWith("/"))) { let url = urlMatch[0] // Skip ellipses and very short non-urls diff --git a/src/util/nostr.ts b/src/util/nostr.ts index 7496b2da..92580c7e 100644 --- a/src/util/nostr.ts +++ b/src/util/nostr.ts @@ -114,7 +114,7 @@ export const isNotification = (e, pubkey) => { export const isRelay = url => typeof url === "string" && // It should have the protocol included - url.match(/^wss?:\/\/.+/) + url.match(/^wss:\/\/.+/) export const isShareableRelay = url => isRelay(url) && diff --git a/src/views/notes/Note.svelte b/src/views/notes/Note.svelte index 88a96041..5630cc3c 100644 --- a/src/views/notes/Note.svelte +++ b/src/views/notes/Note.svelte @@ -1,7 +1,19 @@