Fix a few small bugs

This commit is contained in:
Jonathan Staab 2023-04-10 09:01:51 -05:00
parent e9a2e581d5
commit f2e710c842
5 changed files with 26 additions and 9 deletions

View File

@ -40,7 +40,7 @@ export const initializeRelayList = async () => {
const url = import.meta.env.VITE_DUFFLEPUD_URL + "/relay" const url = import.meta.env.VITE_DUFFLEPUD_URL + "/relay"
const json = await fetchJson(url) 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) { } catch (e) {
warn("Failed to fetch relays list", e) warn("Failed to fetch relays list", e)
} }
@ -88,7 +88,11 @@ export const getAllPubkeyWriteRelays = pubkeys => getAllPubkeyRelays(pubkeys, "w
// Current user // 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 = () => export const getUserReadRelays = () =>
getUserRelays() getUserRelays()

View File

@ -32,7 +32,7 @@
<div in:slide class="relative"> <div in:slide class="relative">
<Media link={annotated[0]} onClose={close} /> <Media link={annotated[0]} onClose={close} />
{#if annotated.length > 1} {#if annotated.length > 1}
<p class="text-gray-500 py-4 text-center underline" on:click={openModal}> <p class="text-gray-500 cursor-pointer py-4 text-center underline" on:click={openModal}>
<i class="fa fa-plus" /> Show {annotated.length} link previews <i class="fa fa-plus" /> Show {annotated.length} link previews
</p> </p>
{/if} {/if}

View File

@ -119,6 +119,7 @@ export const parseContent = content => {
} }
for (; i < text.length; ) { for (; i < text.length; ) {
const prev = last(result)
const tail = text.slice(i) const tail = text.slice(i)
const newLine = tail.match(/^\n+/) const newLine = tail.match(/^\n+/)
@ -162,7 +163,7 @@ export const parseContent = content => {
) )
// Skip url if it's just the end of a filepath // 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] let url = urlMatch[0]
// Skip ellipses and very short non-urls // Skip ellipses and very short non-urls

View File

@ -114,7 +114,7 @@ export const isNotification = (e, pubkey) => {
export const isRelay = url => export const isRelay = url =>
typeof url === "string" && typeof url === "string" &&
// It should have the protocol included // It should have the protocol included
url.match(/^wss?:\/\/.+/) url.match(/^wss:\/\/.+/)
export const isShareableRelay = url => export const isShareableRelay = url =>
isRelay(url) && isRelay(url) &&

View File

@ -1,7 +1,19 @@
<script lang="ts"> <script lang="ts">
import cx from "classnames" import cx from "classnames"
import {nip19} from "nostr-tools" import {nip19} from "nostr-tools"
import {find, sum, last, whereEq, without, uniq, pluck, reject, propEq} from "ramda" import {
sortBy,
identity,
find,
sum,
last,
whereEq,
without,
uniq,
pluck,
reject,
propEq,
} from "ramda"
import {onMount} from "svelte" import {onMount} from "svelte"
import {tweened} from "svelte/motion" import {tweened} from "svelte/motion"
import {slide} from "svelte/transition" import {slide} from "svelte/transition"
@ -477,7 +489,7 @@
<div <div
style="transform: scale(-1, 1)" style="transform: scale(-1, 1)"
class="absolute top-0 right-0 m-3 grid grid-cols-3 gap-2 sm:hidden"> class="absolute top-0 right-0 m-3 grid grid-cols-3 gap-2 sm:hidden">
{#each note.seen_on as url, i} {#each sortBy(identity, note.seen_on) as url, i}
<div class={`cursor-pointer order-${3 - (i % 3)}`}> <div class={`cursor-pointer order-${3 - (i % 3)}`}>
<div <div
class="h-3 w-3 rounded-full border border-solid border-gray-6" class="h-3 w-3 rounded-full border border-solid border-gray-6"
@ -488,10 +500,10 @@
</div> </div>
<!-- Desktop version --> <!-- Desktop version -->
<div <div
class={cx("hidden sm:flex transition-opacity", { class={cx("hidden transition-opacity sm:flex", {
"opacity-0 group-hover:opacity-100": !showEntire, "opacity-0 group-hover:opacity-100": !showEntire,
})}> })}>
{#each note.seen_on as url, i} {#each sortBy(identity, note.seen_on) as url, i}
<Popover triggerType="mouseenter" interactive={false}> <Popover triggerType="mouseenter" interactive={false}>
<div slot="trigger" class="cursor-pointer p-1"> <div slot="trigger" class="cursor-pointer p-1">
<div <div