lint/format
This commit is contained in:
parent
597ebddf82
commit
46965f5945
12 changed files with 60 additions and 52 deletions
|
|
@ -198,7 +198,7 @@ export const checkRelayAccess = async (url: string, claim = "") => {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result[url].status !== PublishStatus.Success) {
|
if (result[url].status !== PublishStatus.Success) {
|
||||||
const message = result[url].message?.replace(/^.*: /, '') || "join request rejected"
|
const message = result[url].message?.replace(/^.*: /, "") || "join request rejected"
|
||||||
|
|
||||||
return `Failed to join relay: ${message}`
|
return `Failed to join relay: ${message}`
|
||||||
}
|
}
|
||||||
|
|
@ -233,10 +233,10 @@ export const checkRelayAuth = async (url: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const attemptRelayAccess = async (url: string, claim = "") =>
|
export const attemptRelayAccess = async (url: string, claim = "") =>
|
||||||
await checkRelayProfile(url) ||
|
(await checkRelayProfile(url)) ||
|
||||||
await checkRelayConnection(url) ||
|
(await checkRelayConnection(url)) ||
|
||||||
await checkRelayAccess(url, claim) ||
|
(await checkRelayAccess(url, claim)) ||
|
||||||
await checkRelayAuth(url)
|
(await checkRelayAuth(url))
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
{@const following = getPubkeyTagValues(getListTags($userFollows)).includes(pubkey)}
|
{@const following = getPubkeyTagValues(getListTags($userFollows)).includes(pubkey)}
|
||||||
<div class="divider" />
|
<div class="divider" />
|
||||||
<Button class="chat chat-start" on:click={onClick}>
|
<Button class="chat chat-start" on:click={onClick}>
|
||||||
<div class="chat-bubble text-left bg-alt">
|
<div class="bg-alt chat-bubble text-left">
|
||||||
<Content hideMedia={!following} {event} />
|
<Content hideMedia={!following} {event} />
|
||||||
<p class="text-right text-xs">{formatTimestamp(event.created_at)}</p>
|
<p class="text-right text-xs">{formatTimestamp(event.created_at)}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||||
import ModalFooter from '@lib/components/ModalFooter.svelte'
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||||
import {addRoomMembership} from "@app/commands"
|
import {addRoomMembership} from "@app/commands"
|
||||||
import {makeSpacePath} from "@app/routes"
|
import {makeSpacePath} from "@app/routes"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,21 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from 'svelte'
|
import {onMount} from "svelte"
|
||||||
import {goto} from '$app/navigation'
|
import {goto} from "$app/navigation"
|
||||||
import {sleep} from '@welshman/lib'
|
import {sleep} from "@welshman/lib"
|
||||||
import {displayRelayUrl} from '@welshman/util'
|
import {displayRelayUrl} 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"
|
||||||
import Spinner from "@lib/components/Spinner.svelte"
|
import Spinner from "@lib/components/Spinner.svelte"
|
||||||
import CardButton from "@lib/components/CardButton.svelte"
|
|
||||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||||
import {attemptRelayAccess} from '@app/commands'
|
import {attemptRelayAccess} from "@app/commands"
|
||||||
import {makeSpacePath} from '@app/routes'
|
import {makeSpacePath} from "@app/routes"
|
||||||
|
|
||||||
export let url
|
export let url
|
||||||
|
|
||||||
const back = () => history.back()
|
const back = () => history.back()
|
||||||
|
|
||||||
const next = () => goto(makeSpacePath(url))
|
const next = () => goto(makeSpacePath(url), {replaceState: true})
|
||||||
|
|
||||||
let error: string | undefined
|
let error: string | undefined
|
||||||
let loading = true
|
let loading = true
|
||||||
|
|
@ -34,22 +33,20 @@
|
||||||
Connecting you to to <span class="text-primary">{displayRelayUrl(url)}</span>
|
Connecting you to to <span class="text-primary">{displayRelayUrl(url)}</span>
|
||||||
</div>
|
</div>
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<div class="flex flex-col m-auto gap-4">
|
<div class="m-auto flex flex-col gap-4">
|
||||||
{#if loading}
|
{#if loading}
|
||||||
<Spinner loading>Hold tight, we're checking your connection.</Spinner>
|
<Spinner loading>Hold tight, we're checking your connection.</Spinner>
|
||||||
{:else if error}
|
{:else if error}
|
||||||
<p>
|
<p>Oops! We ran into some problems:</p>
|
||||||
Oops! We ran into some problems:
|
|
||||||
</p>
|
|
||||||
<p class="card2 bg-alt">{error}</p>
|
<p class="card2 bg-alt">{error}</p>
|
||||||
<p>
|
<p>
|
||||||
If you're not sure what the error message means, you may
|
If you're not sure what the error message means, you may need to contact the space
|
||||||
need to contact the space administrator to get more information.
|
administrator to get more information.
|
||||||
</p>
|
</p>
|
||||||
{:else}
|
{:else}
|
||||||
<p>
|
<p>
|
||||||
Looking good, we were able to connect you to this space!
|
Looking good, we were able to connect you to this space! Click below to continue when you're
|
||||||
Click below to continue when you're ready.
|
ready.
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {goto} from "$app/navigation"
|
import {goto} from "$app/navigation"
|
||||||
import {ctx, tryCatch} from "@welshman/lib"
|
import {tryCatch} from "@welshman/lib"
|
||||||
import {isRelayUrl, normalizeRelayUrl} from "@welshman/util"
|
import {isRelayUrl, normalizeRelayUrl} from "@welshman/util"
|
||||||
import {loadRelay} from "@welshman/app"
|
|
||||||
import CardButton from "@lib/components/CardButton.svelte"
|
import CardButton from "@lib/components/CardButton.svelte"
|
||||||
import Spinner from "@lib/components/Spinner.svelte"
|
import Spinner from "@lib/components/Spinner.svelte"
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import Field from "@lib/components/Field.svelte"
|
import Field from "@lib/components/Field.svelte"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||||
import ModalFooter from '@lib/components/ModalFooter.svelte'
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||||
import InfoRelay from "@app/components/InfoRelay.svelte"
|
import InfoRelay from "@app/components/InfoRelay.svelte"
|
||||||
import {pushToast} from "@app/toast"
|
import {pushToast} from "@app/toast"
|
||||||
import {pushModal} from "@app/modal"
|
import {pushModal} from "@app/modal"
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@ import {
|
||||||
REACTION,
|
REACTION,
|
||||||
ZAP_RESPONSE,
|
ZAP_RESPONSE,
|
||||||
DIRECT_MESSAGE,
|
DIRECT_MESSAGE,
|
||||||
EVENT_DATE,
|
|
||||||
EVENT_TIME,
|
|
||||||
getRelayTagValues,
|
getRelayTagValues,
|
||||||
isShareableRelayUrl,
|
isShareableRelayUrl,
|
||||||
getPubkeyTagValues,
|
getPubkeyTagValues,
|
||||||
|
|
@ -216,7 +214,7 @@ export const deriveEventsForUrl = (url: string, kinds: number[]) =>
|
||||||
Array.from($tracker.getIds(url))
|
Array.from($tracker.getIds(url))
|
||||||
.map(id => repository.eventsById.get(id)!)
|
.map(id => repository.eventsById.get(id)!)
|
||||||
.filter(e => kinds.includes(e?.kind)),
|
.filter(e => kinds.includes(e?.kind)),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Membership
|
// Membership
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
<div class="flex flex-row items-center justify-between gap-4 mt-4">
|
<div class="mt-4 flex flex-row items-center justify-between gap-4">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,17 @@
|
||||||
import {browser} from "$app/environment"
|
import {browser} from "$app/environment"
|
||||||
import {sleep, take, sortBy, ago, now, HOUR} from "@welshman/lib"
|
import {sleep, take, sortBy, ago, now, HOUR} from "@welshman/lib"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import {PROFILE, REACTION, ZAP_RESPONSE, FOLLOWS, RELAYS, INBOX_RELAYS, WRAP, getPubkeyTagValues, getListTags} from "@welshman/util"
|
import {
|
||||||
|
PROFILE,
|
||||||
|
REACTION,
|
||||||
|
ZAP_RESPONSE,
|
||||||
|
FOLLOWS,
|
||||||
|
RELAYS,
|
||||||
|
INBOX_RELAYS,
|
||||||
|
WRAP,
|
||||||
|
getPubkeyTagValues,
|
||||||
|
getListTags,
|
||||||
|
} from "@welshman/util"
|
||||||
import {throttled} from "@welshman/store"
|
import {throttled} from "@welshman/store"
|
||||||
import {
|
import {
|
||||||
relays,
|
relays,
|
||||||
|
|
@ -104,7 +114,7 @@
|
||||||
|
|
||||||
// Inflate the score for profiles/relays/follows to avoid redundant fetches
|
// Inflate the score for profiles/relays/follows to avoid redundant fetches
|
||||||
// Demote non-metadata type events, and introduce recency bias
|
// Demote non-metadata type events, and introduce recency bias
|
||||||
score *= metaKinds.includes(e.kind) ? 2 : (e.created_at / now())
|
score *= metaKinds.includes(e.kind) ? 2 : e.created_at / now()
|
||||||
|
|
||||||
return score
|
return score
|
||||||
}
|
}
|
||||||
|
|
@ -116,8 +126,7 @@
|
||||||
return data.filter(({value}) => value < cutoff)
|
return data.filter(({value}) => value < cutoff)
|
||||||
}
|
}
|
||||||
|
|
||||||
const migratePlaintext = (data: {key: string; value: number}[]) =>
|
const migratePlaintext = (data: {key: string; value: number}[]) => data.slice(0, 10_000)
|
||||||
data.slice(0, 10_000)
|
|
||||||
|
|
||||||
const migrateEvents = (events: TrustedEvent[]) => {
|
const migrateEvents = (events: TrustedEvent[]) => {
|
||||||
if (events.length < 50_000) {
|
if (events.length < 50_000) {
|
||||||
|
|
@ -126,7 +135,10 @@
|
||||||
|
|
||||||
const scoreEvent = getScoreEvent()
|
const scoreEvent = getScoreEvent()
|
||||||
|
|
||||||
return take(30_000, sortBy(e => -scoreEvent(e), events))
|
return take(
|
||||||
|
30_000,
|
||||||
|
sortBy(e => -scoreEvent(e), events),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!db) {
|
if (!db) {
|
||||||
|
|
@ -135,8 +147,14 @@
|
||||||
relays: {keyPath: "url", store: throttled(1000, relays)},
|
relays: {keyPath: "url", store: throttled(1000, relays)},
|
||||||
handles: {keyPath: "nip05", store: throttled(1000, handles)},
|
handles: {keyPath: "nip05", store: throttled(1000, handles)},
|
||||||
publishStatus: storageAdapters.fromObjectStore(publishStatusData),
|
publishStatus: storageAdapters.fromObjectStore(publishStatusData),
|
||||||
freshness: storageAdapters.fromObjectStore(freshness, {throttle: 1000, migrate: migrateFreshness}),
|
freshness: storageAdapters.fromObjectStore(freshness, {
|
||||||
plaintext: storageAdapters.fromObjectStore(plaintext, {throttle: 1000, migrate: migratePlaintext}),
|
throttle: 1000,
|
||||||
|
migrate: migrateFreshness,
|
||||||
|
}),
|
||||||
|
plaintext: storageAdapters.fromObjectStore(plaintext, {
|
||||||
|
throttle: 1000,
|
||||||
|
migrate: migratePlaintext,
|
||||||
|
}),
|
||||||
tracker: storageAdapters.fromTracker(tracker, {throttle: 1000}),
|
tracker: storageAdapters.fromTracker(tracker, {throttle: 1000}),
|
||||||
}).then(() => sleep(300))
|
}).then(() => sleep(300))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
import RelayDescription from "@app/components/RelayDescription.svelte"
|
import RelayDescription from "@app/components/RelayDescription.svelte"
|
||||||
import SpaceCheck from "@app/components/SpaceCheck.svelte"
|
import SpaceCheck from "@app/components/SpaceCheck.svelte"
|
||||||
import {userMembership, discoverRelays, getMembershipUrls} from "@app/state"
|
import {userMembership, discoverRelays, getMembershipUrls} from "@app/state"
|
||||||
import {pushModal} from '@app/modal'
|
import {pushModal} from "@app/modal"
|
||||||
|
|
||||||
const openSpace = (url: string) => pushModal(SpaceCheck, {url})
|
const openSpace = (url: string) => pushModal(SpaceCheck, {url})
|
||||||
|
|
||||||
|
|
@ -54,11 +54,12 @@
|
||||||
idKey="url"
|
idKey="url"
|
||||||
let:item={relay}>
|
let:item={relay}>
|
||||||
<Button
|
<Button
|
||||||
class="card2 bg-alt text-left flex flex-col gap-2 shadow-xl transition-all hover:shadow-2xl hover:brightness-[1.1]"
|
class="card2 bg-alt flex flex-col gap-2 text-left shadow-xl transition-all hover:shadow-2xl hover:brightness-[1.1]"
|
||||||
on:click={() => openSpace(relay.url)}>
|
on:click={() => openSpace(relay.url)}>
|
||||||
<div class="flex gap-4">
|
<div class="flex gap-4">
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
<div class="center !flex h-12 w-12 min-w-12 rounded-full border-2 border-solid border-base-300 bg-base-300">
|
<div
|
||||||
|
class="center !flex h-12 w-12 min-w-12 rounded-full border-2 border-solid border-base-300 bg-base-300">
|
||||||
{#if relay.profile?.icon}
|
{#if relay.profile?.icon}
|
||||||
<img alt="" src={relay.profile.icon} />
|
<img alt="" src={relay.profile.icon} />
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {ago} from "@welshman/lib"
|
import {displayRelayUrl} from "@welshman/util"
|
||||||
import {displayRelayUrl, REACTION, NOTE, EVENT_DATE, EVENT_TIME, CLASSIFIED} from "@welshman/util"
|
|
||||||
import {subscribe} from "@welshman/app"
|
|
||||||
import {fly, slide} from "@lib/transition"
|
import {fly, slide} from "@lib/transition"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import Page from "@lib/components/Page.svelte"
|
import Page from "@lib/components/Page.svelte"
|
||||||
|
|
@ -20,11 +18,9 @@
|
||||||
getMembershipRoomsByUrl,
|
getMembershipRoomsByUrl,
|
||||||
getMembershipUrls,
|
getMembershipUrls,
|
||||||
userMembership,
|
userMembership,
|
||||||
pullConservatively,
|
|
||||||
roomsByUrl,
|
roomsByUrl,
|
||||||
decodeNRelay,
|
decodeNRelay,
|
||||||
GENERAL,
|
GENERAL,
|
||||||
MESSAGE,
|
|
||||||
} from "@app/state"
|
} from "@app/state"
|
||||||
import {checkRelayConnection, checkRelayAuth} from "@app/commands"
|
import {checkRelayConnection, checkRelayAuth} from "@app/commands"
|
||||||
import {pushModal} from "@app/modal"
|
import {pushModal} from "@app/modal"
|
||||||
|
|
@ -63,7 +59,7 @@
|
||||||
$: otherRooms = ($roomsByUrl.get(url) || []).filter(room => !rooms.concat(GENERAL).includes(room))
|
$: otherRooms = ($roomsByUrl.get(url) || []).filter(room => !rooms.concat(GENERAL).includes(room))
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const error = await checkRelayConnection(url) || await checkRelayAuth(url)
|
const error = (await checkRelayConnection(url)) || (await checkRelayAuth(url))
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
pushToast({theme: "error", message: error})
|
pushToast({theme: "error", message: error})
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from 'svelte'
|
import {onMount} from "svelte"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {sortBy, last, ago} from "@welshman/lib"
|
import {sortBy, last, ago} from "@welshman/lib"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import {EVENT_DATE, EVENT_TIME} from "@welshman/util"
|
import {EVENT_DATE, EVENT_TIME} from "@welshman/util"
|
||||||
import {repository, subscribe, formatTimestampAsDate, trackerStore} from "@welshman/app"
|
import {subscribe, formatTimestampAsDate} from "@welshman/app"
|
||||||
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"
|
||||||
import Spinner from "@lib/components/Spinner.svelte"
|
import Spinner from "@lib/components/Spinner.svelte"
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
dateDisplay?: string
|
dateDisplay?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$: items = sortBy(getStart, $events).reduce<Item[]>((r, event) => {
|
$: items = sortBy(getStart, $events).reduce<Item[]>((r, event) => {
|
||||||
const prevDateDisplay =
|
const prevDateDisplay =
|
||||||
r.length > 0 ? formatTimestampAsDate(getStart(last(r).event)) : undefined
|
r.length > 0 ? formatTimestampAsDate(getStart(last(r).event)) : undefined
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {NOTE} from "@welshman/util"
|
import {NOTE} from "@welshman/util"
|
||||||
import {feedFromFilter} from "@welshman/feeds"
|
import {feedFromFilter} from "@welshman/feeds"
|
||||||
import {ago, nthEq, sortBy} from "@welshman/lib"
|
import {nthEq} from "@welshman/lib"
|
||||||
import {repository, trackerStore, feedLoader} from "@welshman/app"
|
import {feedLoader} from "@welshman/app"
|
||||||
import {createScroller} from "@lib/html"
|
import {createScroller} from "@lib/html"
|
||||||
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"
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
import ThreadItem from "@app/components/ThreadItem.svelte"
|
import ThreadItem from "@app/components/ThreadItem.svelte"
|
||||||
import ThreadCreate from "@app/components/ThreadCreate.svelte"
|
import ThreadCreate from "@app/components/ThreadCreate.svelte"
|
||||||
import {pushModal} from "@app/modal"
|
import {pushModal} from "@app/modal"
|
||||||
import {pullConservatively, deriveEventsForUrl, decodeNRelay} from "@app/state"
|
import {deriveEventsForUrl, decodeNRelay} from "@app/state"
|
||||||
|
|
||||||
const url = decodeNRelay($page.params.nrelay)
|
const url = decodeNRelay($page.params.nrelay)
|
||||||
const kinds = [NOTE]
|
const kinds = [NOTE]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue