Small zap fixes, lengthen delay for onChunk

This commit is contained in:
Jonathan Staab 2023-03-07 17:50:26 -06:00
parent 6714eac7e0
commit b2f74b7fcd
7 changed files with 20 additions and 17 deletions

View File

@ -2,6 +2,7 @@
- [ ] Collapse relaycard and relaycardsimple? - [ ] Collapse relaycard and relaycardsimple?
- [ ] Review sampleRelays, seems like we shouldn't be shuffling
- [ ] Go over onboarding process, suggest some good relays for newcomers - [ ] Go over onboarding process, suggest some good relays for newcomers
- [ ] Submit blog post with new onboarding process built in - [ ] Submit blog post with new onboarding process built in
- [ ] Fix hover on notes in modal - [ ] Fix hover on notes in modal

View File

@ -21,11 +21,11 @@ const getStalePubkeys = pubkeys => {
}) })
} }
const listen = ({relays, filter, onChunk = null, shouldProcess = true}) => { const listen = ({relays, filter, onChunk = null, shouldProcess = true, delay = 500}) => {
return pool.subscribe({ return pool.subscribe({
filter, filter,
relays, relays,
onEvent: batch(300, chunk => { onEvent: batch(delay, chunk => {
if (shouldProcess) { if (shouldProcess) {
sync.processEvents(chunk) sync.processEvents(chunk)
} }

View File

@ -41,13 +41,15 @@ const processProfileEvents = async events => {
0: () => tryJson(() => { 0: () => tryJson(() => {
const kind0 = JSON.parse(e.content) const kind0 = JSON.parse(e.content)
if (e.created_at > (person.kind0_updated_at || 0)) { if (e.created_at >= (person.kind0_updated_at || 0)) {
if (kind0.nip05) { if (kind0.nip05) {
verifyNip05(e.pubkey, kind0.nip05) verifyNip05(e.pubkey, kind0.nip05)
} }
if (kind0.lud16 || kind0.lud06) { const address = kind0.lud16 || kind0.lud06
verifyZapper(e.pubkey, kind0.lud16 || kind0.lud06)
if (address) {
verifyZapper(e.pubkey, address)
} }
return { return {
@ -310,7 +312,7 @@ const verifyZapper = async (pubkey, address) => {
let url let url
// Try to parse it as a lud06 LNURL or as a lud16 address // Try to parse it as a lud06 LNURL or as a lud16 address
if (address.startsWith('lnurl1')) { if (address.toLowerCase().startsWith('lnurl1')) {
url = lnurlDecode(address) url = lnurlDecode(address)
} else if (address.includes('@')) { } else if (address.includes('@')) {
const [name, domain] = address.split('@') const [name, domain] = address.split('@')

View File

@ -92,7 +92,6 @@ const user = {
canPublish, canPublish,
getProfile: () => profileCopy, getProfile: () => profileCopy,
getPubkey: () => profileCopy?.pubkey, getPubkey: () => profileCopy?.pubkey,
canZap: () => profileCopy?.zapper,
muffle: events => { muffle: events => {
const muffle = user.getMuffle() const muffle = user.getMuffle()

View File

@ -166,6 +166,7 @@ const listen = async pubkey => {
} }
listener = await network.listen({ listener = await network.listen({
delay: 10000,
relays: getUserReadRelays(), relays: getUserReadRelays(),
filter: [ filter: [
{kinds: personKinds, authors: [pubkey], since}, {kinds: personKinds, authors: [pubkey], since},

View File

@ -2,7 +2,6 @@ import type {DisplayEvent} from 'src/util/types'
import {omit, sortBy} from 'ramda' import {omit, sortBy} from 'ramda'
import {createMap, ellipsize} from 'hurdak/lib/hurdak' import {createMap, ellipsize} from 'hurdak/lib/hurdak'
import {renderContent} from 'src/util/html' import {renderContent} from 'src/util/html'
import {sleep} from 'src/util/misc'
import {displayPerson, findReplyId} from 'src/util/nostr' import {displayPerson, findReplyId} from 'src/util/nostr'
import {getUserFollows} from 'src/agent/social' import {getUserFollows} from 'src/agent/social'
import {getUserReadRelays} from 'src/agent/relays' import {getUserReadRelays} from 'src/agent/relays'
@ -14,13 +13,11 @@ import {routes, modal, toast} from 'src/app/ui'
export const loadAppData = async pubkey => { export const loadAppData = async pubkey => {
if (getUserReadRelays().length > 0) { if (getUserReadRelays().length > 0) {
// Delay since this gets in the way of quickly loading feeds very often // Start our listener, but don't wait for it
await sleep(5000) alerts.listen(pubkey)
await Promise.all([ // Make sure the user's network is loaded
alerts.listen(pubkey), await network.loadPeople(getUserFollows())
network.loadPeople(getUserFollows()),
])
} }
} }

View File

@ -121,7 +121,7 @@
$: $zapsTotal = sum(zaps.map(zap => zap.invoiceAmount)) / 1000 $: $zapsTotal = sum(zaps.map(zap => zap.invoiceAmount)) / 1000
$: $repliesCount = note.replies.length $: $repliesCount = note.replies.length
$: visibleNotes = note.replies.filter(r => showContext ? true : !r.isContext) $: visibleNotes = note.replies.filter(r => showContext ? true : !r.isContext)
$: canZap = $person?.zapper && user.canZap() $: canZap = $person?.zapper
const onClick = e => { const onClick = e => {
const target = e.target as HTMLElement const target = e.target as HTMLElement
@ -405,8 +405,11 @@
<i class={cx('fa fa-heart cursor-pointer', {'fa-beat fa-beat-custom': like})} /> <i class={cx('fa fa-heart cursor-pointer', {'fa-beat fa-beat-custom': like})} />
{$likesCount} {$likesCount}
</button> </button>
<button class="w-20 text-left" class:text-accent={zapped} on:click|stopPropagation={startZap}> <button
<i class={cx("fa fa-bolt cursor-pointer", {'pointer-events-none opacity-50': !canZap})} /> class={cx("w-20 text-left", {'pointer-events-none opacity-50': !canZap})}
class:text-accent={zapped}
on:click|stopPropagation={startZap}>
<i class="fa fa-bolt cursor-pointer" />
{formatSats($zapsTotal)} {formatSats($zapsTotal)}
</button> </button>
<button class="w-16 text-left" on:click|stopPropagation={() => react("-")}> <button class="w-16 text-left" on:click|stopPropagation={() => react("-")}>