(subId: string, event: RelayEvent)
| 788 | } |
| 789 | |
| 790 | private handleEvent(subId: string, event: RelayEvent) { |
| 791 | const subscription = this.subscriptions.get(subId); |
| 792 | if (!subscription) { |
| 793 | return; |
| 794 | } |
| 795 | |
| 796 | if (subscription.mode === "history") { |
| 797 | subscription.events.push(event); |
| 798 | return; |
| 799 | } |
| 800 | |
| 801 | subscription.lastSeenCreatedAt = Math.max( |
| 802 | subscription.lastSeenCreatedAt ?? 0, |
| 803 | event.created_at, |
| 804 | ); |
| 805 | |
| 806 | this.eventBuffer.push({ subId, event }); |
| 807 | this.flushTimeout ??= window.setTimeout( |
| 808 | () => this.flushEventBuffer(), |
| 809 | EVENT_BATCH_MS, |
| 810 | ); |
| 811 | } |
| 812 | |
| 813 | private flushEventBuffer() { |
| 814 | this.flushTimeout = null; |
no test coverage detected