(filter: RelaySubscriptionFilter)
| 231 | } |
| 232 | |
| 233 | private requestHistory(filter: RelaySubscriptionFilter) { |
| 234 | return new Promise<RelayEvent[]>((resolve, reject) => { |
| 235 | const subId = `history-${crypto.randomUUID()}`; |
| 236 | const timeout = window.setTimeout(() => { |
| 237 | this.subscriptions.delete(subId); |
| 238 | void this.closeSubscription(subId); |
| 239 | reject(new Error("Timed out while loading channel history.")); |
| 240 | }, 8_000); |
| 241 | |
| 242 | this.subscriptions.set(subId, { |
| 243 | mode: "history", |
| 244 | events: [], |
| 245 | resolve, |
| 246 | reject, |
| 247 | timeout, |
| 248 | }); |
| 249 | |
| 250 | void this.sendRaw(["REQ", subId, filter]).catch((error) => { |
| 251 | window.clearTimeout(timeout); |
| 252 | this.subscriptions.delete(subId); |
| 253 | reject( |
| 254 | error instanceof Error |
| 255 | ? error |
| 256 | : new Error("Failed to request channel history."), |
| 257 | ); |
| 258 | }); |
| 259 | }); |
| 260 | } |
| 261 | |
| 262 | async sendMessage( |
| 263 | channelId: string, |
no test coverage detected