forked from coracle/flotilla
Update welshman stuff, fix bug in makeFeed
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
"@welshman/lib": "^0.1.2",
|
||||
"@welshman/net": "^0.1.2",
|
||||
"@welshman/relay": "^0.1.2",
|
||||
"@welshman/router": "^0.1.0",
|
||||
"@welshman/signer": "^0.1.4",
|
||||
"@welshman/store": "^0.1.3",
|
||||
"@welshman/util": "^0.1.3",
|
||||
@@ -84,6 +85,7 @@
|
||||
"@welshman/feeds": "link:../welshman/packages/feeds",
|
||||
"@welshman/net": "link:../welshman/packages/net",
|
||||
"@welshman/relay": "link:../welshman/packages/relay",
|
||||
"@welshman/router": "link:../welshman/packages/router",
|
||||
"@welshman/signer": "link:../welshman/packages/signer",
|
||||
"@welshman/store": "link:../welshman/packages/store",
|
||||
"@welshman/editor": "link:../welshman/packages/editor"
|
||||
|
||||
Generated
+4
@@ -13,6 +13,7 @@ overrides:
|
||||
'@welshman/feeds': link:../welshman/packages/feeds
|
||||
'@welshman/net': link:../welshman/packages/net
|
||||
'@welshman/relay': link:../welshman/packages/relay
|
||||
'@welshman/router': link:../welshman/packages/router
|
||||
'@welshman/signer': link:../welshman/packages/signer
|
||||
'@welshman/store': link:../welshman/packages/store
|
||||
'@welshman/editor': link:../welshman/packages/editor
|
||||
@@ -87,6 +88,9 @@ importers:
|
||||
'@welshman/relay':
|
||||
specifier: link:../welshman/packages/relay
|
||||
version: link:../welshman/packages/relay
|
||||
'@welshman/router':
|
||||
specifier: link:../welshman/packages/router
|
||||
version: link:../welshman/packages/router
|
||||
'@welshman/signer':
|
||||
specifier: link:../welshman/packages/signer
|
||||
version: link:../welshman/packages/signer
|
||||
|
||||
+4
-4
@@ -33,6 +33,7 @@ import {
|
||||
import type {TrustedEvent, Filter, EventContent, EventTemplate} from "@welshman/util"
|
||||
import {Pool, PublishStatus, AuthStatus, SocketStatus} from "@welshman/net"
|
||||
import {Nip59, stamp} from "@welshman/signer"
|
||||
import {Router} from "@welshman/router"
|
||||
import {
|
||||
pubkey,
|
||||
signer,
|
||||
@@ -53,7 +54,6 @@ import {
|
||||
dropSession,
|
||||
tagEventForComment,
|
||||
tagEventForQuote,
|
||||
Router,
|
||||
thunkIsComplete,
|
||||
} from "@welshman/app"
|
||||
import type {Thunk} from "@welshman/app"
|
||||
@@ -259,7 +259,7 @@ export const setInboxRelayPolicy = (url: string, enabled: boolean) => {
|
||||
// Relay access
|
||||
|
||||
export const checkRelayAccess = async (url: string, claim = "") => {
|
||||
const socket = Pool.getSingleton().get(url)
|
||||
const socket = Pool.get().get(url)
|
||||
|
||||
await socket.auth.attemptAuth(signer.get().sign)
|
||||
|
||||
@@ -291,7 +291,7 @@ export const checkRelayProfile = async (url: string) => {
|
||||
}
|
||||
|
||||
export const checkRelayConnection = async (url: string) => {
|
||||
const socket = Pool.getSingleton().get(url)
|
||||
const socket = Pool.get().get(url)
|
||||
|
||||
socket.attemptToOpen()
|
||||
|
||||
@@ -306,7 +306,7 @@ export const checkRelayConnection = async (url: string) => {
|
||||
}
|
||||
|
||||
export const checkRelayAuth = async (url: string, timeout = 3000) => {
|
||||
const socket = Pool.getSingleton().get(url)
|
||||
const socket = Pool.get().get(url)
|
||||
const okStatuses = [AuthStatus.None, AuthStatus.Ok]
|
||||
|
||||
await socket.auth.attemptAuth(signer.get().sign)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {parseJson, nthEq} from "@welshman/lib"
|
||||
import {parseJson, displayList, nthEq} from "@welshman/lib"
|
||||
import {
|
||||
getAddress,
|
||||
getTagValue,
|
||||
@@ -9,7 +9,6 @@
|
||||
MESSAGE,
|
||||
THREAD,
|
||||
} from "@welshman/util"
|
||||
import {displayList} from "@lib/util"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {goto} from "$app/navigation"
|
||||
import {nthEq} from "@welshman/lib"
|
||||
import {Router, tracker, repository} from "@welshman/app"
|
||||
import {Router} from "@welshman/router"
|
||||
import {tracker, repository} from "@welshman/app"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {Address, DIRECT_MESSAGE, MESSAGE, THREAD, EVENT_TIME} from "@welshman/util"
|
||||
import {scrollToEvent} from "@lib/html"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {Router} from "@welshman/app"
|
||||
import {Router} from "@welshman/router"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import FieldInline from "@lib/components/FieldInline.svelte"
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {getListTags, getPubkeyTagValues} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {formatTimestamp, Router, userMutes} from "@welshman/app"
|
||||
import {Router} from "@welshman/router"
|
||||
import {formatTimestamp, userMutes} from "@welshman/app"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
import type {Filter} from "@welshman/util"
|
||||
import {deriveEvents} from "@welshman/store"
|
||||
import {load} from "@welshman/net"
|
||||
import {Router, repository, loadRelaySelections, formatTimestampRelative} from "@welshman/app"
|
||||
import {Router} from "@welshman/router"
|
||||
import {repository, loadRelaySelections, formatTimestampRelative} from "@welshman/app"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
isPublishedProfile,
|
||||
uniqTags,
|
||||
} from "@welshman/util"
|
||||
import {Router, pubkey, profilesByPubkey, publishThunk} from "@welshman/app"
|
||||
import {Router} from "@welshman/router"
|
||||
import {pubkey, profilesByPubkey, publishThunk} from "@welshman/app"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
|
||||
import {clearModals} from "@app/modal"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {feedFromFilter, makeIntersectionFeed, makeRelayFeed} from "@welshman/feeds"
|
||||
import {NOTE, getReplyTags} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {createFeedController} from "@welshman/app"
|
||||
import {makeFeedController} from "@welshman/app"
|
||||
import {createScroller} from "@lib/html"
|
||||
import {fly} from "@lib/transition"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
let {url, pubkey, events = $bindable([]), hideLoading = false}: Props = $props()
|
||||
|
||||
const ctrl = createFeedController({
|
||||
const ctrl = makeFeedController({
|
||||
useWindowing: true,
|
||||
feed: makeIntersectionFeed(
|
||||
makeRelayFeed(url),
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import type {Snippet} from "svelte"
|
||||
import {groupBy, uniq, uniqBy, batch} from "@welshman/lib"
|
||||
import {groupBy, uniq, uniqBy, batch, displayList} from "@welshman/lib"
|
||||
import {REACTION, getReplyFilters, getTag, REPORT, DELETE} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {deriveEvents} from "@welshman/store"
|
||||
import {load} from "@welshman/net"
|
||||
import {pubkey, repository, displayProfileByPubkey} from "@welshman/app"
|
||||
import {displayList} from "@lib/util"
|
||||
import {isMobile, preventDefault, stopPropagation} from "@lib/html"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import EventReportDetails from "@app/components/EventReportDetails.svelte"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
const back = () => history.back()
|
||||
|
||||
const next = () => {
|
||||
if (!error && Pool.getSingleton().get(url).auth.status === AuthStatus.None) {
|
||||
if (!error && Pool.get().get(url).auth.status === AuthStatus.None) {
|
||||
pushModal(SpaceVisitConfirm, {url}, {replaceState: true})
|
||||
} else {
|
||||
confirmSpaceVisit(url)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
return pushToast({theme: "error", message: error})
|
||||
}
|
||||
|
||||
const socket = Pool.getSingleton().get(url)
|
||||
const socket = Pool.get().get(url)
|
||||
|
||||
if (socket.auth.status === AuthStatus.None) {
|
||||
pushModal(SpaceJoinConfirm, {url}, {replaceState: true})
|
||||
|
||||
@@ -2,7 +2,8 @@ import {mount} from "svelte"
|
||||
import type {Writable} from "svelte/store"
|
||||
import {get} from "svelte/store"
|
||||
import type {StampedEvent} from "@welshman/util"
|
||||
import {Router, signer, profileSearch} from "@welshman/app"
|
||||
import {Router} from "@welshman/router"
|
||||
import {signer, profileSearch} from "@welshman/app"
|
||||
import {Editor, MentionSuggestion, WelshmanExtension} from "@welshman/editor"
|
||||
import {getSetting, userSettingValues} from "@app/state"
|
||||
import {makeMentionNodeView} from "./MentionNodeView"
|
||||
|
||||
+28
-11
@@ -35,7 +35,7 @@ import {
|
||||
pull,
|
||||
hasNegentropy,
|
||||
thunkQueue,
|
||||
createFeedController,
|
||||
makeFeedController,
|
||||
loadRelay,
|
||||
loadMutes,
|
||||
loadFollows,
|
||||
@@ -102,7 +102,7 @@ export const makeFeed = ({
|
||||
const events = writable(initialEvents)
|
||||
const controller = new AbortController()
|
||||
|
||||
for (const event of initialEvents) {
|
||||
const markEvent = (event: TrustedEvent) => {
|
||||
if (!seen.has(event.id)) {
|
||||
seen.add(event.id)
|
||||
onEvent?.(event)
|
||||
@@ -110,19 +110,32 @@ export const makeFeed = ({
|
||||
}
|
||||
|
||||
const insertEvent = (event: TrustedEvent) => {
|
||||
buffer.update($buffer => {
|
||||
for (let i = 0; i < $buffer.length; i++) {
|
||||
if ($buffer[i].id === event.id) return $buffer
|
||||
if ($buffer[i].created_at < event.created_at) return insertAt(i, event, $buffer)
|
||||
let handled = false
|
||||
|
||||
events.update($events => {
|
||||
for (let i = 0; i < $events.length; i++) {
|
||||
if ($events[i].id === event.id) return $events
|
||||
if ($events[i].created_at < event.created_at) {
|
||||
handled = true
|
||||
return insertAt(i, event, $events)
|
||||
}
|
||||
}
|
||||
|
||||
return [...$buffer, event]
|
||||
return $events
|
||||
})
|
||||
|
||||
if (!seen.has(event.id)) {
|
||||
seen.add(event.id)
|
||||
onEvent?.(event)
|
||||
if (!handled) {
|
||||
buffer.update($buffer => {
|
||||
for (let i = 0; i < $buffer.length; i++) {
|
||||
if ($buffer[i].id === event.id) return $buffer
|
||||
if ($buffer[i].created_at < event.created_at) return insertAt(i, event, $buffer)
|
||||
}
|
||||
|
||||
return [...$buffer, event]
|
||||
})
|
||||
}
|
||||
|
||||
markEvent(event)
|
||||
}
|
||||
|
||||
const removeEvents = (ids: string[]) => {
|
||||
@@ -144,13 +157,17 @@ export const makeFeed = ({
|
||||
}
|
||||
}
|
||||
|
||||
const ctrl = createFeedController({
|
||||
const ctrl = makeFeedController({
|
||||
useWindowing: true,
|
||||
feed: makeIntersectionFeed(makeRelayFeed(...relays), feedFromFilters(feedFilters)),
|
||||
onEvent: insertEvent,
|
||||
onExhausted,
|
||||
})
|
||||
|
||||
for (const event of initialEvents) {
|
||||
markEvent(event)
|
||||
}
|
||||
|
||||
request({
|
||||
relays,
|
||||
signal: controller.signal,
|
||||
|
||||
+1
-2
@@ -43,6 +43,7 @@ import {
|
||||
} from "@welshman/util"
|
||||
import type {TrustedEvent, SignedEvent, PublishedList, List, Filter} from "@welshman/util"
|
||||
import {Nip59, decrypt} from "@welshman/signer"
|
||||
import {routerContext, Router} from "@welshman/router"
|
||||
import {
|
||||
pubkey,
|
||||
repository,
|
||||
@@ -60,9 +61,7 @@ import {
|
||||
thunks,
|
||||
walkThunks,
|
||||
signer,
|
||||
Router,
|
||||
makeOutboxLoader,
|
||||
routerContext,
|
||||
appContext,
|
||||
} from "@welshman/app"
|
||||
import type {Thunk, Relay} from "@welshman/app"
|
||||
|
||||
@@ -2,20 +2,6 @@ import {hexToBytes, bytesToHex} from "@noble/hashes/utils"
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {range, DAY} from "@welshman/lib"
|
||||
|
||||
export const displayList = <T>(xs: T[], conj = "and", n = 6, locale = "en-US") => {
|
||||
const stringItems = xs.map(String)
|
||||
|
||||
if (xs.length > n + 2) {
|
||||
const formattedList = new Intl.ListFormat(locale, {style: "long", type: "unit"}).format(
|
||||
stringItems.slice(0, n),
|
||||
)
|
||||
|
||||
return `${formattedList}, ${conj} ${xs.length - n} others`
|
||||
}
|
||||
|
||||
return new Intl.ListFormat(locale, {style: "long", type: "conjunction"}).format(stringItems)
|
||||
}
|
||||
|
||||
export const nsecEncode = (secret: string) => nip19.nsecEncode(hexToBytes(secret))
|
||||
|
||||
export const nsecDecode = (nsec: string) => {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import {page} from "$app/stores"
|
||||
import {WRAP} from "@welshman/util"
|
||||
import {pubkey, Router} from "@welshman/app"
|
||||
import {Router} from "@welshman/router"
|
||||
import {pubkey} from "@welshman/app"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Page from "@lib/components/Page.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {getListTags, createEvent, getPubkeyTagValues, MUTES} from "@welshman/util"
|
||||
import {pubkey, Router, signer, userMutes, tagPubkey, publishThunk} from "@welshman/app"
|
||||
import {Router} from "@welshman/router"
|
||||
import {pubkey, signer, userMutes, tagPubkey, publishThunk} from "@welshman/app"
|
||||
import {preventDefault} from "@lib/html"
|
||||
import Field from "@lib/components/Field.svelte"
|
||||
import FieldInline from "@lib/components/FieldInline.svelte"
|
||||
|
||||
Reference in New Issue
Block a user