mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 19:07:06 +00:00
lint/format
This commit is contained in:
@@ -198,7 +198,7 @@ export const checkRelayAccess = async (url: string, claim = "") => {
|
||||
})
|
||||
|
||||
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}`
|
||||
}
|
||||
@@ -233,10 +233,10 @@ export const checkRelayAuth = async (url: string) => {
|
||||
}
|
||||
|
||||
export const attemptRelayAccess = async (url: string, claim = "") =>
|
||||
await checkRelayProfile(url) ||
|
||||
await checkRelayConnection(url) ||
|
||||
await checkRelayAccess(url, claim) ||
|
||||
await checkRelayAuth(url)
|
||||
(await checkRelayProfile(url)) ||
|
||||
(await checkRelayConnection(url)) ||
|
||||
(await checkRelayAccess(url, claim)) ||
|
||||
(await checkRelayAuth(url))
|
||||
|
||||
// Actions
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
{@const following = getPubkeyTagValues(getListTags($userFollows)).includes(pubkey)}
|
||||
<div class="divider" />
|
||||
<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} />
|
||||
<p class="text-right text-xs">{formatTimestamp(event.created_at)}</p>
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Icon from "@lib/components/Icon.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 {makeSpacePath} from "@app/routes"
|
||||
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from 'svelte'
|
||||
import {goto} from '$app/navigation'
|
||||
import {sleep} from '@welshman/lib'
|
||||
import {displayRelayUrl} from '@welshman/util'
|
||||
import {onMount} from "svelte"
|
||||
import {goto} from "$app/navigation"
|
||||
import {sleep} from "@welshman/lib"
|
||||
import {displayRelayUrl} from "@welshman/util"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import CardButton from "@lib/components/CardButton.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import {attemptRelayAccess} from '@app/commands'
|
||||
import {makeSpacePath} from '@app/routes'
|
||||
import {attemptRelayAccess} from "@app/commands"
|
||||
import {makeSpacePath} from "@app/routes"
|
||||
|
||||
export let url
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const next = () => goto(makeSpacePath(url))
|
||||
const next = () => goto(makeSpacePath(url), {replaceState: true})
|
||||
|
||||
let error: string | undefined
|
||||
let loading = true
|
||||
@@ -34,22 +33,20 @@
|
||||
Connecting you to to <span class="text-primary">{displayRelayUrl(url)}</span>
|
||||
</div>
|
||||
</ModalHeader>
|
||||
<div class="flex flex-col m-auto gap-4">
|
||||
<div class="m-auto flex flex-col gap-4">
|
||||
{#if loading}
|
||||
<Spinner loading>Hold tight, we're checking your connection.</Spinner>
|
||||
{:else if error}
|
||||
<p>
|
||||
Oops! We ran into some problems:
|
||||
</p>
|
||||
<p>Oops! We ran into some problems:</p>
|
||||
<p class="card2 bg-alt">{error}</p>
|
||||
<p>
|
||||
If you're not sure what the error message means, you may
|
||||
need to contact the space administrator to get more information.
|
||||
If you're not sure what the error message means, you may need to contact the space
|
||||
administrator to get more information.
|
||||
</p>
|
||||
{:else}
|
||||
<p>
|
||||
Looking good, we were able to connect you to this space!
|
||||
Click below to continue when you're ready.
|
||||
Looking good, we were able to connect you to this space! Click below to continue when you're
|
||||
ready.
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<script lang="ts">
|
||||
import {goto} from "$app/navigation"
|
||||
import {ctx, tryCatch} from "@welshman/lib"
|
||||
import {tryCatch} from "@welshman/lib"
|
||||
import {isRelayUrl, normalizeRelayUrl} from "@welshman/util"
|
||||
import {loadRelay} from "@welshman/app"
|
||||
import CardButton from "@lib/components/CardButton.svelte"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Field from "@lib/components/Field.svelte"
|
||||
import Icon from "@lib/components/Icon.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 {pushToast} from "@app/toast"
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
@@ -22,8 +22,6 @@ import {
|
||||
REACTION,
|
||||
ZAP_RESPONSE,
|
||||
DIRECT_MESSAGE,
|
||||
EVENT_DATE,
|
||||
EVENT_TIME,
|
||||
getRelayTagValues,
|
||||
isShareableRelayUrl,
|
||||
getPubkeyTagValues,
|
||||
@@ -216,7 +214,7 @@ export const deriveEventsForUrl = (url: string, kinds: number[]) =>
|
||||
Array.from($tracker.getIds(url))
|
||||
.map(id => repository.eventsById.get(id)!)
|
||||
.filter(e => kinds.includes(e?.kind)),
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
// 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 />
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,17 @@
|
||||
import {browser} from "$app/environment"
|
||||
import {sleep, take, sortBy, ago, now, HOUR} from "@welshman/lib"
|
||||
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 {
|
||||
relays,
|
||||
@@ -104,7 +114,7 @@
|
||||
|
||||
// Inflate the score for profiles/relays/follows to avoid redundant fetches
|
||||
// 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
|
||||
}
|
||||
@@ -116,8 +126,7 @@
|
||||
return data.filter(({value}) => value < cutoff)
|
||||
}
|
||||
|
||||
const migratePlaintext = (data: {key: string; value: number}[]) =>
|
||||
data.slice(0, 10_000)
|
||||
const migratePlaintext = (data: {key: string; value: number}[]) => data.slice(0, 10_000)
|
||||
|
||||
const migrateEvents = (events: TrustedEvent[]) => {
|
||||
if (events.length < 50_000) {
|
||||
@@ -126,7 +135,10 @@
|
||||
|
||||
const scoreEvent = getScoreEvent()
|
||||
|
||||
return take(30_000, sortBy(e => -scoreEvent(e), events))
|
||||
return take(
|
||||
30_000,
|
||||
sortBy(e => -scoreEvent(e), events),
|
||||
)
|
||||
}
|
||||
|
||||
if (!db) {
|
||||
@@ -135,8 +147,14 @@
|
||||
relays: {keyPath: "url", store: throttled(1000, relays)},
|
||||
handles: {keyPath: "nip05", store: throttled(1000, handles)},
|
||||
publishStatus: storageAdapters.fromObjectStore(publishStatusData),
|
||||
freshness: storageAdapters.fromObjectStore(freshness, {throttle: 1000, migrate: migrateFreshness}),
|
||||
plaintext: storageAdapters.fromObjectStore(plaintext, {throttle: 1000, migrate: migratePlaintext}),
|
||||
freshness: storageAdapters.fromObjectStore(freshness, {
|
||||
throttle: 1000,
|
||||
migrate: migrateFreshness,
|
||||
}),
|
||||
plaintext: storageAdapters.fromObjectStore(plaintext, {
|
||||
throttle: 1000,
|
||||
migrate: migratePlaintext,
|
||||
}),
|
||||
tracker: storageAdapters.fromTracker(tracker, {throttle: 1000}),
|
||||
}).then(() => sleep(300))
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import RelayDescription from "@app/components/RelayDescription.svelte"
|
||||
import SpaceCheck from "@app/components/SpaceCheck.svelte"
|
||||
import {userMembership, discoverRelays, getMembershipUrls} from "@app/state"
|
||||
import {pushModal} from '@app/modal'
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
const openSpace = (url: string) => pushModal(SpaceCheck, {url})
|
||||
|
||||
@@ -54,11 +54,12 @@
|
||||
idKey="url"
|
||||
let:item={relay}>
|
||||
<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)}>
|
||||
<div class="flex gap-4">
|
||||
<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}
|
||||
<img alt="" src={relay.profile.icon} />
|
||||
{:else}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {page} from "$app/stores"
|
||||
import {ago} from "@welshman/lib"
|
||||
import {displayRelayUrl, REACTION, NOTE, EVENT_DATE, EVENT_TIME, CLASSIFIED} from "@welshman/util"
|
||||
import {subscribe} from "@welshman/app"
|
||||
import {displayRelayUrl} from "@welshman/util"
|
||||
import {fly, slide} from "@lib/transition"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Page from "@lib/components/Page.svelte"
|
||||
@@ -20,11 +18,9 @@
|
||||
getMembershipRoomsByUrl,
|
||||
getMembershipUrls,
|
||||
userMembership,
|
||||
pullConservatively,
|
||||
roomsByUrl,
|
||||
decodeNRelay,
|
||||
GENERAL,
|
||||
MESSAGE,
|
||||
} from "@app/state"
|
||||
import {checkRelayConnection, checkRelayAuth} from "@app/commands"
|
||||
import {pushModal} from "@app/modal"
|
||||
@@ -63,7 +59,7 @@
|
||||
$: otherRooms = ($roomsByUrl.get(url) || []).filter(room => !rooms.concat(GENERAL).includes(room))
|
||||
|
||||
onMount(async () => {
|
||||
const error = await checkRelayConnection(url) || await checkRelayAuth(url)
|
||||
const error = (await checkRelayConnection(url)) || (await checkRelayAuth(url))
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from 'svelte'
|
||||
import {onMount} from "svelte"
|
||||
import {page} from "$app/stores"
|
||||
import {sortBy, last, ago} from "@welshman/lib"
|
||||
import type {TrustedEvent} 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 Button from "@lib/components/Button.svelte"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
@@ -31,7 +31,6 @@
|
||||
dateDisplay?: string
|
||||
}
|
||||
|
||||
|
||||
$: items = sortBy(getStart, $events).reduce<Item[]>((r, event) => {
|
||||
const prevDateDisplay =
|
||||
r.length > 0 ? formatTimestampAsDate(getStart(last(r).event)) : undefined
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import {page} from "$app/stores"
|
||||
import {NOTE} from "@welshman/util"
|
||||
import {feedFromFilter} from "@welshman/feeds"
|
||||
import {ago, nthEq, sortBy} from "@welshman/lib"
|
||||
import {repository, trackerStore, feedLoader} from "@welshman/app"
|
||||
import {nthEq} from "@welshman/lib"
|
||||
import {feedLoader} from "@welshman/app"
|
||||
import {createScroller} from "@lib/html"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
@@ -13,7 +13,7 @@
|
||||
import ThreadItem from "@app/components/ThreadItem.svelte"
|
||||
import ThreadCreate from "@app/components/ThreadCreate.svelte"
|
||||
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 kinds = [NOTE]
|
||||
|
||||
Reference in New Issue
Block a user