diff --git a/README.md b/README.md index 68788b5a..498a9912 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ If you like Coracle and want to support its development, you can donate sats via # Changelog +## 0.2.4 + +- [x] Fix reactions - livequery is required in order to listen for changes + ## 0.2.3 - [x] Fix reactions - we'll show new reactions optimistically to avoid complexity in listeners diff --git a/src/partials/Like.svelte b/src/partials/Like.svelte index 9c3bc2d7..bf91d240 100644 --- a/src/partials/Like.svelte +++ b/src/partials/Like.svelte @@ -1,5 +1,6 @@ @@ -40,11 +39,11 @@
{ addNotes(newNotes); newNotes = [] }}> + on:click={() => { until = now() }}> Load {quantify(newNotesLength, 'new note')}
{/if} - {#each notes as n (n.id)} + {#each visibleNotes as n (n.id)}
  • {/each} diff --git a/src/views/notes/Global.svelte b/src/views/notes/Global.svelte index b616c469..6e140701 100644 --- a/src/views/notes/Global.svelte +++ b/src/views/notes/Global.svelte @@ -6,17 +6,13 @@ import {getTagValues} from 'src/util/nostr' import relay, {user} from 'src/relay' - let notes, sub + let sub onMount(async () => { sub = await relay.pool.listenForEvents( 'views/notes/Global', [{kinds: [1, 5, 7], since: cursor.since}], - when(propEq('kind', 1), async e => { - await relay.loadNoteContext(e) - - notes.addNewNotes([e]) - }) + when(propEq('kind', 1), relay.loadNoteContext) ) }) @@ -28,21 +24,22 @@ const cursor = new Cursor(timedelta(1, 'minutes')) - const loadNotes = async () => { + const loadNotes = () => { const [since, until] = cursor.step() - await relay.pool.loadEvents( + return relay.pool.loadEvents( [{kinds: [1, 5, 7], since, until}], when(propEq('kind', 1), relay.loadNoteContext) ) + } + const queryNotes = () => { return relay.filterEvents({ - since, - until, kinds: [1], + since: cursor.since, muffle: getTagValues($user?.muffle || []), }) } - + diff --git a/src/views/notes/Network.svelte b/src/views/notes/Network.svelte index 1f3e0b26..4ce362cd 100644 --- a/src/views/notes/Network.svelte +++ b/src/views/notes/Network.svelte @@ -6,7 +6,7 @@ import {getTagValues} from 'src/util/nostr' import relay, {user, network} from 'src/relay' - let notes, sub, networkUnsub + let sub, networkUnsub onMount(() => { // We need to re-create the sub when network changes, since this is where @@ -16,11 +16,7 @@ sub = await relay.pool.listenForEvents( 'views/notes/Network', [{kinds: [1, 5, 7], authors: $network, since: cursor.since}], - when(propEq('kind', 1), async e => { - await relay.loadNoteContext(e) - - notes.addNewNotes([e]) - }) + when(propEq('kind', 1), relay.loadNoteContext) ) }) }) @@ -35,23 +31,24 @@ const cursor = new Cursor(timedelta(10, 'minutes')) - const loadNotes = async () => { + const loadNotes = () => { const [since, until] = cursor.step() - await relay.pool.loadEvents( + return relay.pool.loadEvents( [{kinds: [1, 5, 7], authors: $network, since, until}], when(propEq('kind', 1), relay.loadNoteContext) ) + } + const queryNotes = () => { return relay.filterEvents({ - since, - until, kinds: [1], + since: cursor.since, authors: $network.concat($user.pubkey), muffle: getTagValues($user?.muffle || []), }) } - + diff --git a/src/views/person/Likes.svelte b/src/views/person/Likes.svelte index 78c87ce1..2d65cc76 100644 --- a/src/views/person/Likes.svelte +++ b/src/views/person/Likes.svelte @@ -8,16 +8,21 @@ const cursor = new Cursor(timedelta(1, 'days')) - const loadNotes = async () => { + const loadNotes = () => { const [since, until] = cursor.step() - const filter = {kinds: [7], authors: [pubkey], since, until} - const muffle = getTagValues($user?.muffle || []) - await relay.pool.loadEvents(filter) + return relay.pool.loadEvents({kinds: [7], authors: [pubkey], since, until}) + } - return relay.filterEvents({...filter, muffle}) + const queryNotes = () => { + return relay.filterEvents({ + kinds: [7], + since: cursor.since, + authors: [pubkey], + muffle: getTagValues($user?.muffle || []), + }) } - + diff --git a/src/views/person/Network.svelte b/src/views/person/Network.svelte index fbc4300b..5306bbb2 100644 --- a/src/views/person/Network.svelte +++ b/src/views/person/Network.svelte @@ -10,15 +10,24 @@ const loadNotes = async () => { const [since, until] = cursor.step() - const authors = getTagValues(person.petnames) - const filter = {kinds: [1], authors, since, until} - const muffle = getTagValues($user?.muffle || []) - await relay.pool.loadEvents(filter) + return relay.pool.loadEvents({ + since, + until, + kinds: [1], + authors: getTagValues(person.petnames), + }) + } - return relay.filterEvents({...filter, muffle}) + const queryNotes = () => { + return relay.filterEvents({ + kinds: [1], + since: cursor.since, + authors: getTagValues(person.petnames), + muffle: getTagValues($user?.muffle || []), + }) } - + diff --git a/src/views/person/Notes.svelte b/src/views/person/Notes.svelte index 03711a51..a61973fa 100644 --- a/src/views/person/Notes.svelte +++ b/src/views/person/Notes.svelte @@ -7,15 +7,23 @@ const cursor = new Cursor(timedelta(1, 'days')) - const loadNotes = async () => { + const loadNotes = () => { const [since, until] = cursor.step() - const filter = {kinds: [1], authors: [pubkey], since, until} - await relay.pool.loadEvents(filter, relay.loadNoteContext) + return relay.pool.loadEvents( + [{kinds: [1], authors: [pubkey], since, until}], + relay.loadNoteContext + ) + } - return relay.filterEvents(filter) + const queryNotes = () => { + return relay.filterEvents({ + kinds: [1], + since: cursor.since, + authors: [pubkey], + }) } - +