Fix cursor

This commit is contained in:
Jonathan Staab 2023-04-28 10:35:45 -05:00
parent 6595e0a9be
commit a14bbe8cfc
2 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,5 @@
# Current
- [ ] Fix cursor
- [ ] Add coupon code registration for relay
- [ ] Repurpose chat as groups
- [ ] Avoid leaking events from private relays

View File

@ -1,5 +1,6 @@
import type {MyEvent, Relay} from "src/util/types"
import {
max,
without,
mergeLeft,
fromPairs,
@ -131,7 +132,7 @@ class Cursor {
const untilCopy = {...this.until}
if (this.delta) {
this.since -= this.delta
this.since = Object.values(this.until).reduce(max, 0) - this.delta
}
await Promise.all(
@ -145,8 +146,10 @@ class Cursor {
),
onChunk: events => {
for (const event of events) {
if (event.created_at < this.until[event.seen_on]) {
this.until[event.seen_on] = event.created_at
for (const url of event.seen_on) {
if (event.created_at < this.until[url]) {
this.until[url] = event.created_at
}
}
if (this.seen.has(event.id)) {