remove throttle and update event from repository

This commit is contained in:
Jon Staab
2024-06-04 17:43:21 -07:00
parent 0b74b00d85
commit 41729d8245
-16
View File
@@ -1,4 +1,3 @@
import {throttle} from 'throttle-debounce'
import {flatten, nth, Emitter, sortBy, inc, chunk, sleep, uniq, omit, now, range, identity} from '@welshman/lib'
import {DELETE} from './Kinds'
import {EPOCH, matchFilter} from './Filters'
@@ -11,12 +10,6 @@ export const DAY = 86400
const getDay = (ts: number) => Math.floor(ts / DAY)
const maybeThrottle = (t: number | undefined, f: () => void) => t ? throttle(t, f) : f
export type RepositoryOptions = {
throttle?: number
}
export class Repository extends Emitter {
eventsById = new Map<string, TrustedEvent>()
eventsByAddress = new Map<string, TrustedEvent>()
@@ -25,10 +18,6 @@ export class Repository extends Emitter {
eventsByAuthor = new Map<string, TrustedEvent[]>()
deletes = new Map<string, number>()
constructor(private options: RepositoryOptions) {
super()
}
// Dump/load/clear
dump = () => {
@@ -60,10 +49,6 @@ export class Repository extends Emitter {
// Notify methods
notifyUpdate = maybeThrottle(this.options.throttle, () => {
this.emit('update')
})
notifyEvent = (event: TrustedEvent) => {
this.emit('event', event)
}
@@ -195,7 +180,6 @@ export class Repository extends Emitter {
}
if (!this.isDeleted(event)) {
this.notifyUpdate()
this.notifyEvent(event)
// Deletes are tricky, re-evaluate all subscriptions if that's what we're dealing with