Improve quote loading

This commit is contained in:
Jonathan Staab 2023-09-25 15:19:04 -07:00
parent 167e5786f7
commit 2fa274ffee
5 changed files with 21 additions and 10 deletions

View File

@ -20,6 +20,7 @@
- [x] Use a bloom filter for deletes
- [x] Remember reply drafts
- [x] Topic/keyword mutes
- [x] Improve quote loading
# 0.3.6

View File

@ -11,8 +11,9 @@
loadPubkeys,
displayPubkey,
isEventMuted,
getEventHints,
getParentHints,
isShareableRelay,
getUserRelayUrls,
mergeHints,
} from "src/engine"
@ -26,13 +27,15 @@
const openPerson = pubkey => modal.push({type: "person/detail", pubkey})
const {id, identifier, kind, pubkey} = value
const relays = mergeHints([
// Agora social has a bug
(value.relays || []).flatMap(r => r.split(",")).filter(isShareableRelay),
getUserRelayUrls("read"),
getParentHints(note),
])
load({
relays: mergeHints([
// Agora social has a bug
(value.relays || []).flatMap(r => r.split(",")).filter(isShareableRelay),
getEventHints(note),
]),
relays,
filters: [
id
? {ids: [id]}
@ -56,7 +59,7 @@
// stopPropagation wasn't working for some reason
if (noteId && e.target.textContent !== "Show") {
modal.push({type: "note/detail", note: {id: noteId}})
modal.push({type: "note/detail", note: quote || {id: noteId}, relays})
}
}

View File

@ -29,7 +29,7 @@ export const execute = () => {
return
}
info(`Loading ${queue.length} grouped requests`, filters)
const nRequests = queue.length
const itemsByRelay = {}
for (const item of queue.splice(0)) {
@ -38,6 +38,8 @@ export const execute = () => {
}
}
info(`Loading ${nRequests} grouped requests`, filters)
const tracker = new Tracker()
// Group by relay, then by filter
@ -80,6 +82,10 @@ export const execute = () => {
}
export const load = (request: LoadOpts) => {
if (request.filters.length === 0) {
return Promise.resolve([])
}
const result = defer()
if (queue.length === 0) {

View File

@ -44,7 +44,7 @@ export const displayRelay = ({url}: Relay) => last(url.split("://"))
export const getRelaySearch = $relays => fuzzy($relays, {keys: ["url", "name", "description"]})
export const getSearchableRelays = $relays => {
const urls = $relays.filter(r => (r.info?.supported_nips || []).includes(50)).map(prop("url"))
const urls = pluck('url', $relays.filter(r => (r.info?.supported_nips || []).includes(50)))
return uniq(env.get().SEARCH_RELAYS.concat(urls)).slice(0, 8) as string[]
}

View File

@ -130,7 +130,8 @@ export const findRoot = (e: Event) => prop("root", findReplyAndRoot(e))
export const findRootId = (e: Event) => findRoot(e)?.[1]
export const isLike = (content: string) => ["", "+", "🤙", "👍", "❤️", "😎", "🏅"].includes(content)
export const isLike = (content: string) =>
["", "+", "🤙", "👍", "❤️", "😎", "🏅", "🫂"].includes(content)
export const channelAttrs = ["name", "about", "picture"]