Upgrade to welshman 0.11.0
This commit is contained in:
parent
7cb3feeeb3
commit
6b5947ae0e
29 changed files with 48 additions and 43 deletions
|
|
@ -314,7 +314,7 @@ data every page needs lives in `src/app/sync.ts`.
|
||||||
|
|
||||||
**One entity, or a handful of lists:** call plugin `load` in `onMount`, and toast on failure, as
|
**One entity, or a handful of lists:** call plugin `load` in `onMount`, and toast on failure, as
|
||||||
`people/[npub]/+page.svelte` does for the profile, relay list, follow, pin, room and messaging
|
`people/[npub]/+page.svelte` does for the profile, relay list, follow, pin, room and messaging
|
||||||
lists before loading the author's outbox with `$network.load`.
|
lists before loading the author's outbox with `$network.loadLenient`.
|
||||||
|
|
||||||
**A detail page:** `deriveEvent(address, [url])` loads when nothing local matches. While it is
|
**A detail page:** `deriveEvent(address, [url])` loads when nothing local matches. While it is
|
||||||
empty, seven pages show a spinner that turns into a failure message:
|
empty, seven pages show a spinner that turns into a failure message:
|
||||||
|
|
|
||||||
20
package.json
20
package.json
|
|
@ -91,16 +91,16 @@
|
||||||
"@types/throttle-debounce": "^5.0.2",
|
"@types/throttle-debounce": "^5.0.2",
|
||||||
"@vite-pwa/assets-generator": "^1.0.2",
|
"@vite-pwa/assets-generator": "^1.0.2",
|
||||||
"@vite-pwa/sveltekit": "^1.1.0",
|
"@vite-pwa/sveltekit": "^1.1.0",
|
||||||
"@welshman/app": "^0.10.9",
|
"@welshman/app": "^0.11.0",
|
||||||
"@welshman/content": "^0.10.9",
|
"@welshman/content": "^0.11.0",
|
||||||
"@welshman/domain": "^0.10.9",
|
"@welshman/domain": "^0.11.0",
|
||||||
"@welshman/editor": "^0.10.9",
|
"@welshman/editor": "^0.11.0",
|
||||||
"@welshman/feeds": "^0.10.9",
|
"@welshman/feeds": "^0.11.0",
|
||||||
"@welshman/lib": "^0.10.9",
|
"@welshman/lib": "^0.11.0",
|
||||||
"@welshman/net": "^0.10.9",
|
"@welshman/net": "^0.11.0",
|
||||||
"@welshman/signer": "^0.10.9",
|
"@welshman/signer": "^0.11.0",
|
||||||
"@welshman/store": "^0.10.9",
|
"@welshman/store": "^0.11.0",
|
||||||
"@welshman/util": "^0.10.9",
|
"@welshman/util": "^0.11.0",
|
||||||
"cheerio": "^1.2.0",
|
"cheerio": "^1.2.0",
|
||||||
"compressorjs-next": "^1.1.2",
|
"compressorjs-next": "^1.1.2",
|
||||||
"dompurify": "^3.4.13",
|
"dompurify": "^3.4.13",
|
||||||
|
|
|
||||||
BIN
pnpm-lock.yaml
BIN
pnpm-lock.yaml
Binary file not shown.
|
|
@ -336,7 +336,7 @@ export const toggleVideoPrimaryTile = (key: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadCallParticipants = (url: string, h: string) =>
|
export const loadCallParticipants = (url: string, h: string) =>
|
||||||
network.get().load({
|
network.get().loadLenient({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
filters: [{kinds: [LIVEKIT_PARTICIPANTS], "#d": [h]}],
|
filters: [{kinds: [LIVEKIT_PARTICIPANTS], "#d": [h]}],
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -48,15 +48,16 @@ export class Commands extends RelayScopedDerivedPlugin<CommandReader> {
|
||||||
const [url, address] = splitCommandKey(key)
|
const [url, address] = splitCommandKey(key)
|
||||||
const {pubkey, identifier} = Address.from(address)
|
const {pubkey, identifier} = Address.from(address)
|
||||||
|
|
||||||
return this.app
|
return this.app.use(Network).loadComplete({
|
||||||
.use(Network)
|
relays: [url],
|
||||||
.load({relays: [url], filters: [{kinds: [COMMAND], authors: [pubkey], "#d": [identifier]}]})
|
filters: [{kinds: [COMMAND], authors: [pubkey], "#d": [identifier]}],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureLoaded = (url: string) => {
|
ensureLoaded = (url: string) => {
|
||||||
if (!this.pulled.has(url)) {
|
if (!this.pulled.has(url)) {
|
||||||
this.pulled.add(url)
|
this.pulled.add(url)
|
||||||
this.app.use(Network).load({relays: [url], filters: [{kinds: [COMMAND]}]})
|
this.app.use(Network).loadLenient({relays: [url], filters: [{kinds: [COMMAND]}]})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@
|
||||||
history.back()
|
history.back()
|
||||||
|
|
||||||
if (shareToChat) {
|
if (shareToChat) {
|
||||||
publishRoomQuote({url, h, parent: calendarThunk.event, protect})
|
publishRoomQuote({url, h, parent: calendarThunk.options.event, protect})
|
||||||
}
|
}
|
||||||
|
|
||||||
pushToast({message: "Your event has been saved!"})
|
pushToast({message: "Your event has been saved!"})
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
const isOwn = event.pubkey === $user.pubkey
|
const isOwn = event.pubkey === $user.pubkey
|
||||||
const profileDisplay = $profiles.display(event.pubkey).$
|
const profileDisplay = $profiles.display(event.pubkey).$
|
||||||
const thunks = $app.use(Thunks).history
|
const thunks = $app.use(Thunks).history
|
||||||
const thunk = $app.use(Thunks).merge($thunks.filter(t => t.event.id === event.id))
|
const thunk = $app.use(Thunks).merge($thunks.filter(t => t.options.event.id === event.id))
|
||||||
const colorValue = colorFor(event.pubkey)
|
const colorValue = colorFor(event.pubkey)
|
||||||
|
|
||||||
const reply = () => replyTo(event)
|
const reply = () => replyTo(event)
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@
|
||||||
history.back()
|
history.back()
|
||||||
|
|
||||||
if (shareToChat) {
|
if (shareToChat) {
|
||||||
publishRoomQuote({url, h, parent: classifiedThunk.event, protect})
|
publishRoomQuote({url, h, parent: classifiedThunk.options.event, protect})
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading = false
|
loading = false
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
mergedRelays.set(urls)
|
mergedRelays.set(urls)
|
||||||
|
|
||||||
if (!$quote) {
|
if (!$quote) {
|
||||||
$network.load({filters: getIdFilters([idOrAddress]), relays: urls})
|
$network.loadLenient({filters: getIdFilters([idOrAddress]), relays: urls})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@
|
||||||
history.back()
|
history.back()
|
||||||
|
|
||||||
if (shareToChat) {
|
if (shareToChat) {
|
||||||
publishRoomQuote({url, h, parent: goalThunk.event, protect})
|
publishRoomQuote({url, h, parent: goalThunk.options.event, protect})
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading = false
|
loading = false
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
back()
|
back()
|
||||||
} else {
|
} else {
|
||||||
pushToast({message: "Shelf created!"})
|
pushToast({message: "Shelf created!"})
|
||||||
navigate(makeLibraryPath(url, getAddress(thunk.event)))
|
navigate(makeLibraryPath(url, getAddress(thunk.options.event)))
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@
|
||||||
history.back()
|
history.back()
|
||||||
|
|
||||||
if (shareToChat) {
|
if (shareToChat) {
|
||||||
publishRoomQuote({url, h, parent: pollThunk.event, protect})
|
publishRoomQuote({url, h, parent: pollThunk.options.event, protect})
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading = false
|
loading = false
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
onDestroy(context.cleanup)
|
onDestroy(context.cleanup)
|
||||||
|
|
||||||
const events = $network.load({
|
const events = $network.loadComplete({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
filters: [{authors: [pubkey], kinds: [NOTE], limit}],
|
filters: [{authors: [pubkey], kinds: [NOTE], limit}],
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
<div class="card card-sm">
|
<div class="card card-sm">
|
||||||
{#if etag}
|
{#if etag}
|
||||||
{#await $network.load({relays: [url, LOCAL_RELAY_URL], filters: getIdFilters([etag[1]])})}
|
{#await $network.loadComplete( {relays: [url, LOCAL_RELAY_URL], filters: getIdFilters( [etag[1]], )}, )}
|
||||||
<p>Loading</p>
|
<p>Loading</p>
|
||||||
{:then reportedEvents}
|
{:then reportedEvents}
|
||||||
{#if reportedEvents.length === 0}
|
{#if reportedEvents.length === 0}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
const message = await thunk.waitForError()
|
const message = await thunk.waitForError()
|
||||||
|
|
||||||
if (message) {
|
if (message) {
|
||||||
$app.repository.removeEvent(thunk.event.id)
|
$app.repository.removeEvent(thunk.options.event.id)
|
||||||
pushToast({theme: "error", message})
|
pushToast({theme: "error", message})
|
||||||
} else {
|
} else {
|
||||||
await $roomLists.removeRoom(h, url).then(publish)
|
await $roomLists.removeRoom(h, url).then(publish)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const events = await $network.load({relays, filters, signal: controller.signal})
|
const events = await $network.loadComplete({relays, filters, signal: controller.signal})
|
||||||
|
|
||||||
results = sortEventsDesc(uniqBy((e: TrustedEvent) => e.id, [...events, ...results]))
|
results = sortEventsDesc(uniqBy((e: TrustedEvent) => e.id, [...events, ...results]))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
history.back()
|
history.back()
|
||||||
|
|
||||||
if (shareToChat) {
|
if (shareToChat) {
|
||||||
publishRoomQuote({url, h: room, parent: thunk.event, protect})
|
publishRoomQuote({url, h: room, parent: thunk.options.event, protect})
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading = false
|
loading = false
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,11 @@
|
||||||
const retry = (url: string) => {
|
const retry = (url: string) => {
|
||||||
for (const child of $thunks.flatten([thunk])) {
|
for (const child of $thunks.flatten([thunk])) {
|
||||||
if (child.options.relays.includes(url)) {
|
if (child.options.relays.includes(url)) {
|
||||||
const retried = $thunks.publish({...child.options, event: child.event, relays: [url]})
|
const retried = $thunks.publish({
|
||||||
|
...child.options,
|
||||||
|
event: child.options.event,
|
||||||
|
relays: [url],
|
||||||
|
})
|
||||||
|
|
||||||
if (showToastOnRetry) {
|
if (showToastOnRetry) {
|
||||||
pushToast({
|
pushToast({
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
const {relays, invoice, filters} = await requestInvoice()
|
const {relays, invoice, filters} = await requestInvoice()
|
||||||
|
|
||||||
await payInvoice(invoice)
|
await payInvoice(invoice)
|
||||||
await $network.load({relays, filters})
|
await $network.loadLenient({relays, filters})
|
||||||
|
|
||||||
pushToast({message: "Zap successfully sent!"})
|
pushToast({message: "Zap successfully sent!"})
|
||||||
back()
|
back()
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ export const makeFeedContext = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadFrom = async (urls: string[], events: TrustedEvent[]) => {
|
const loadFrom = async (urls: string[], events: TrustedEvent[]) => {
|
||||||
const context = await network.get().load({
|
const context = await network.get().loadComplete({
|
||||||
relays: urls,
|
relays: urls,
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
filters: [
|
filters: [
|
||||||
|
|
@ -156,7 +156,7 @@ export const makeFeedContext = ({
|
||||||
})
|
})
|
||||||
|
|
||||||
if (context.length > 0) {
|
if (context.length > 0) {
|
||||||
network.get().load({
|
network.get().loadLenient({
|
||||||
relays: urls,
|
relays: urls,
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
filters: getReplyFilters(context, {kinds: [DELETE]}),
|
filters: getReplyFilters(context, {kinds: [DELETE]}),
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export const derivePinnedEvents = (pubkey: string): Readable<TrustedEvent[]> =>
|
||||||
.get()
|
.get()
|
||||||
.resolver.relays([outbox(pubkey)])
|
.resolver.relays([outbox(pubkey)])
|
||||||
.then($relays =>
|
.then($relays =>
|
||||||
network.get().load({relays: $relays, filters, signal: controller.signal}),
|
network.get().loadLenient({relays: $relays, filters, signal: controller.signal}),
|
||||||
)
|
)
|
||||||
|
|
||||||
const unsubscribe = deriveEvents(filters).subscribe(set)
|
const unsubscribe = deriveEvents(filters).subscribe(set)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export const deriveEvent = (idOrAddress: string, relays: string[] = []) =>
|
||||||
repository: $app.repository,
|
repository: $app.repository,
|
||||||
includeDeleted: true,
|
includeDeleted: true,
|
||||||
onDerive: (filters: Filter[], hints: string[]) =>
|
onDerive: (filters: Filter[], hints: string[]) =>
|
||||||
$app.use(Network).load({filters, relays: hints}),
|
$app.use(Network).loadLenient({filters, relays: hints}),
|
||||||
})(idOrAddress, relays),
|
})(idOrAddress, relays),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export const deriveRoomPinnedEvents = (url: string, h: string): Readable<Trusted
|
||||||
|
|
||||||
const filters = getIdFilters($pins)
|
const filters = getIdFilters($pins)
|
||||||
|
|
||||||
network.get().load({relays: [url], filters, signal: controller.signal})
|
network.get().loadLenient({relays: [url], filters, signal: controller.signal})
|
||||||
|
|
||||||
return deriveEventsForUrl(url, filters).subscribe($events => {
|
return deriveEventsForUrl(url, filters).subscribe($events => {
|
||||||
const byPin = new Map(
|
const byPin = new Map(
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ const syncUserData = () => {
|
||||||
if (authors.length > 0) {
|
if (authors.length > 0) {
|
||||||
const scenario = await router.get().resolve(authors.map(author => outbox(author)))
|
const scenario = await router.get().resolve(authors.map(author => outbox(author)))
|
||||||
|
|
||||||
network.get().load({
|
network.get().loadLenient({
|
||||||
filters: [{kinds: [FOLLOWS, MUTES], authors}],
|
filters: [{kinds: [FOLLOWS, MUTES], authors}],
|
||||||
relays: scenario.limit(8).getUrls(),
|
relays: scenario.limit(8).getUrls(),
|
||||||
})
|
})
|
||||||
|
|
@ -295,7 +295,7 @@ const syncSpace = (url: string) => {
|
||||||
// Which sections a space offers is a question about its whole history rather than about the
|
// Which sections a space offers is a question about its whole history rather than about the
|
||||||
// recent window above — a space whose newest poll is a year old still has polls. One event
|
// recent window above — a space whose newest poll is a year old still has polls. One event
|
||||||
// per kind answers it.
|
// per kind answers it.
|
||||||
network.get().load({
|
network.get().loadLenient({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
filters: CONTENT_KINDS.map(kind => ({kinds: [kind], limit: 1})),
|
filters: CONTENT_KINDS.map(kind => ({kinds: [kind], limit: 1})),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ export const thunksByEventId = derived(
|
||||||
const byId = new Map<string, Thunk[]>()
|
const byId = new Map<string, Thunk[]>()
|
||||||
|
|
||||||
for (const thunk of $history) {
|
for (const thunk of $history) {
|
||||||
pushToMapKey(byId, thunk.event.id, thunk)
|
pushToMapKey(byId, thunk.options.event.id, thunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hand back the array from last time wherever an event's thunks are unchanged. A row derives
|
// Hand back the array from last time wherever an event's thunks are unchanged. A row derives
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
let found = false
|
let found = false
|
||||||
|
|
||||||
$network.load({
|
$network.loadComplete({
|
||||||
relays: [LOCAL_RELAY_URL, ...data.relays],
|
relays: [LOCAL_RELAY_URL, ...data.relays],
|
||||||
filters: getIdFilters([type === "nevent" ? data.id : Address.fromNaddr(bech32).toString()]),
|
filters: getIdFilters([type === "nevent" ? data.id : Address.fromNaddr(bech32).toString()]),
|
||||||
onEvent: (event: TrustedEvent) => {
|
onEvent: (event: TrustedEvent) => {
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
filters.push({kinds: [FOLLOWS], "#p": [pubkey], limit: 500})
|
filters.push({kinds: [FOLLOWS], "#p": [pubkey], limit: 500})
|
||||||
}
|
}
|
||||||
|
|
||||||
$network.load({
|
$network.loadLenient({
|
||||||
relays: await $router.resolver.relays([outbox(pubkey)]),
|
relays: await $router.resolver.relays([outbox(pubkey)]),
|
||||||
filters,
|
filters,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -145,10 +145,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
draftKey.clear()
|
draftKey.clear()
|
||||||
goto(makeArticlePath(url, getAddress(thunk.event)))
|
goto(makeArticlePath(url, getAddress(thunk.options.event)))
|
||||||
|
|
||||||
if (shareToChat) {
|
if (shareToChat) {
|
||||||
publishRoomQuote({url, h, parent: thunk.event, protect})
|
publishRoomQuote({url, h, parent: thunk.options.event, protect})
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading = false
|
loading = false
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
|
|
||||||
$network
|
$network
|
||||||
.load({relays: [url], filters: [{kinds: [PINBOARD, PIN]}], signal: controller.signal})
|
.loadLenient({relays: [url], filters: [{kinds: [PINBOARD, PIN]}], signal: controller.signal})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loading = false
|
loading = false
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue