diff --git a/src/agent/pool.ts b/src/agent/pool.ts index eb3484ec..f1947d75 100644 --- a/src/agent/pool.ts +++ b/src/agent/pool.ts @@ -183,7 +183,7 @@ const subscribe = async (relays, filters, {onEvent, onEose}: Record[]> => { +const request = (relays, filters, {threshold = 0.5} = {}): Promise[]> => { return new Promise(async resolve => { relays = uniqBy(prop('url'), relays.filter(r => isRelay(r.url))) threshold = relays.length * threshold diff --git a/src/app/loaders.ts b/src/app/loaders.ts index ad0cedbf..5797d628 100644 --- a/src/app/loaders.ts +++ b/src/app/loaders.ts @@ -77,6 +77,9 @@ const loadContext = async (relays, notes, {loadParents = false, depth = 0, ...op events = events.concat(await loadContext(parentRelays, parents, opts)) } + // Load missing people from replies etc + await loadPeople(relays, pluck('pubkey', events)) + // We're recurring and so may end up with duplicates here return uniqBy(prop('id'), events) }) diff --git a/src/partials/Note.svelte b/src/partials/Note.svelte index dd432b85..fbf70250 100644 --- a/src/partials/Note.svelte +++ b/src/partials/Note.svelte @@ -34,7 +34,7 @@ const showEntire = anchorId === note.id const interactive = !anchorId || !showEntire const relays = getEventRelays(note) - const person = database.watch('people', p => p.get(note.pubkey) || {pubkey: note.pubkey}) + const person = database.watch('people', () => database.getPersonWithFallback(note.pubkey)) let likes, flags, like, flag diff --git a/src/util/html.ts b/src/util/html.ts index acf01348..0fb1d715 100644 --- a/src/util/html.ts +++ b/src/util/html.ts @@ -73,15 +73,23 @@ export const fromParentOffset = (element, offset): [HTMLElement, number] => { throw new Error("Unable to find parent offset") } -export const extractUrls = url => - url.match(/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?!&//=]*)/gi) +export const extractUrls = content => { + const regex = /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z]{1,6}\b([-a-zA-Z0-9@:%_\+.~#?!&//=;]*)/gi + const urls = content.match(regex) + + return (urls || []) + // Skip decimals like 3.5 and ellipses which have more than one dot in a row + .filter(url => !url.match(/^[\d\.]+$/) && !url.match(/\.{2}/)) + // Add protocol on to the beginning of the url + .map(url => url.startsWith('http') ? url : '//' + url) +} export const renderContent = content => { // Escape html content = escapeHtml(content) // Extract urls - for (const url of extractUrls(content) || []) { + for (const url of extractUrls(content)) { const $a = document.createElement('a') $a.href = url