lint/format
This commit is contained in:
@@ -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