Improve loading, including crucial bug preventing merged subscriptions from completing
This commit is contained in:
@@ -5,6 +5,7 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
|
||||
import {repository, load} from './core'
|
||||
import {collection} from './collection'
|
||||
import {ensurePlaintext} from './plaintext'
|
||||
import {loadRelaySelections} from './relaySelections'
|
||||
|
||||
export const follows = withGetter(
|
||||
deriveEventsMapped<PublishedList>(repository, {
|
||||
@@ -27,6 +28,8 @@ export const {
|
||||
name: "follows",
|
||||
store: follows,
|
||||
getKey: follows => follows.event.pubkey,
|
||||
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
||||
load({...request, filters: [{kinds: [FOLLOWS], authors: [pubkey]}]}),
|
||||
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) => {
|
||||
await loadRelaySelections(pubkey, request)
|
||||
await load({...request, filters: [{kinds: [FOLLOWS], authors: [pubkey]}]})
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {writable, derived} from 'svelte/store'
|
||||
import {withGetter} from '@welshman/store'
|
||||
import {type SubscribeRequest} from "@welshman/net"
|
||||
import {ctx, fetchJson, uniq, batcher, postJson, last} from '@welshman/lib'
|
||||
import {ctx, tryCatch, fetchJson, uniq, batcher, postJson, last} from '@welshman/lib'
|
||||
import {collection} from './collection'
|
||||
import {deriveProfile} from './profiles'
|
||||
|
||||
@@ -49,14 +49,14 @@ export const fetchHandles = async (nip05s: string[]) => {
|
||||
|
||||
// Use dufflepud if we it's set up to protect user privacy, otherwise fetch directly
|
||||
if (base) {
|
||||
const res: any = await postJson(`${base}/handle/info`, {handles: nip05s})
|
||||
const res: any = await tryCatch(async () => await postJson(`${base}/handle/info`, {handles: nip05s}))
|
||||
|
||||
for (const {handle: nip05, info} of res?.data || []) {
|
||||
handlesByNip05.set(nip05, info)
|
||||
}
|
||||
} else {
|
||||
const results = await Promise.all(
|
||||
nip05s.map(async nip05 => ({nip05, info: await queryProfile(nip05)}))
|
||||
nip05s.map(async nip05 => ({nip05, info: await tryCatch(async () => await queryProfile(nip05))}))
|
||||
)
|
||||
|
||||
for (const {nip05, info} of results) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
|
||||
import {repository, load} from './core'
|
||||
import {collection} from './collection'
|
||||
import {ensurePlaintext} from './plaintext'
|
||||
import {loadRelaySelections} from './relaySelections'
|
||||
|
||||
export const mutes = withGetter(
|
||||
deriveEventsMapped<PublishedList>(repository, {
|
||||
@@ -27,6 +28,8 @@ export const {
|
||||
name: "mutes",
|
||||
store: mutes,
|
||||
getKey: mute => mute.event.pubkey,
|
||||
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
||||
load({...request, filters: [{kinds: [MUTES], authors: [pubkey]}]}),
|
||||
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) => {
|
||||
await loadRelaySelections(pubkey, request)
|
||||
await load({...request, filters: [{kinds: [MUTES], authors: [pubkey]}]})
|
||||
},
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ import {deriveEventsMapped, withGetter} from '@welshman/store'
|
||||
import {repository, load} from './core'
|
||||
import {createSearch} from './util'
|
||||
import {collection} from './collection'
|
||||
import {loadRelaySelections} from './relaySelections'
|
||||
|
||||
export const profiles = withGetter(
|
||||
deriveEventsMapped<PublishedProfile>(repository, {
|
||||
@@ -23,8 +24,10 @@ export const {
|
||||
name: "profiles",
|
||||
store: profiles,
|
||||
getKey: profile => profile.event.pubkey,
|
||||
load: (pubkey: string, request: Partial<SubscribeRequest> = {}) =>
|
||||
load({...request, filters: [{kinds: [PROFILE], authors: [pubkey]}]}),
|
||||
load: async (pubkey: string, request: Partial<SubscribeRequest> = {}) => {
|
||||
await loadRelaySelections(pubkey, request)
|
||||
await load({...request, filters: [{kinds: [PROFILE], authors: [pubkey]}]})
|
||||
},
|
||||
})
|
||||
|
||||
export const profileSearch = derived(profiles, $profiles =>
|
||||
|
||||
@@ -533,7 +533,8 @@ export const getFilterSelectionsForIndexedKinds = (state: FilterSelectionRuleSta
|
||||
}
|
||||
|
||||
export const getFilterSelectionsForAuthors = (state: FilterSelectionRuleState) => {
|
||||
if (!state.filter.authors) return false
|
||||
// If we have a ton of authors, just use our indexers
|
||||
if (!state.filter.authors || state.filter.authors.length > 30) return false
|
||||
|
||||
const id = getFilterId(state.filter)
|
||||
const scenario = ctx.app.router.FromPubkeys(state.filter.authors!).update(assoc('value', id))
|
||||
|
||||
@@ -15,7 +15,7 @@ export const fetchZappers = async (lnurls: string[]) => {
|
||||
// Use dufflepud if we it's set up to protect user privacy, otherwise fetch directly
|
||||
if (base) {
|
||||
const hexUrls = lnurls.map(lnurl => tryCatch(() => bech32ToHex(lnurl))).filter(identity)
|
||||
const res: any = await postJson(`${base}/zapper/info`, {lnurls: hexUrls})
|
||||
const res: any = await tryCatch(async () => await postJson(`${base}/zapper/info`, {lnurls: hexUrls}))
|
||||
|
||||
for (const {lnurl, info} of res?.data || []) {
|
||||
tryCatch(() => zappersByLnurl.set(hexToBech32("lnurl", lnurl), info))
|
||||
@@ -24,7 +24,7 @@ export const fetchZappers = async (lnurls: string[]) => {
|
||||
const results = await Promise.all(
|
||||
lnurls.map(async lnurl => {
|
||||
const hexUrl = tryCatch(() => bech32ToHex(lnurl))
|
||||
const info = hexUrl ? await fetchJson(hexUrl) : undefined
|
||||
const info = hexUrl ? await tryCatch(async () => await fetchJson(hexUrl)) : undefined
|
||||
|
||||
return {lnurl, hexUrl, info}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user