|
1 | | -import type { Channel, StreamChat } from 'stream-chat'; |
| 1 | +import type { Channel, Event, StreamChat } from 'stream-chat'; |
2 | 2 |
|
3 | 3 | import { |
4 | | - websocketEventTemplateDefinitions, |
5 | 4 | type SupportedWebsocketEventType, |
6 | 5 | type WebSocketEventTemplateContext, |
| 6 | + websocketEventTemplateDefinitions, |
7 | 7 | } from './websocketEventTemplates'; |
8 | 8 | import type { SimulationState, SimulationUser } from './types'; |
9 | 9 |
|
10 | 10 | type JsonObject = Record<string, unknown>; |
11 | | -type HandleEventArgument = Parameters<StreamChat['handleEvent']>[0]; |
12 | 11 |
|
13 | 12 | const messageTextFragments = [ |
14 | 13 | 'debug event payload', |
@@ -454,7 +453,7 @@ export const trackSimulationStateFromPayload = ({ |
454 | 453 | simulationState, |
455 | 454 | templateContext, |
456 | 455 | }: { |
457 | | - payload: JsonObject; |
| 456 | + payload: Event; |
458 | 457 | simulationState: SimulationState; |
459 | 458 | templateContext: WebSocketEventTemplateContext; |
460 | 459 | }) => { |
@@ -511,18 +510,16 @@ export const emitWebSocketEventPayload = ({ |
511 | 510 | }: { |
512 | 511 | client: StreamChat; |
513 | 512 | eventType: SupportedWebsocketEventType; |
514 | | - payload: JsonObject; |
| 513 | + payload: Event; |
515 | 514 | simulationState: SimulationState; |
516 | 515 | templateContext: WebSocketEventTemplateContext; |
517 | 516 | }) => { |
518 | | - const emittedPayload = { |
| 517 | + const emittedPayload: Event = { |
519 | 518 | ...payload, |
520 | 519 | type: eventType, |
521 | 520 | }; |
522 | 521 |
|
523 | | - client.handleEvent({ |
524 | | - data: JSON.stringify(emittedPayload), |
525 | | - } as HandleEventArgument); |
| 522 | + client.dispatchEvent(emittedPayload); |
526 | 523 |
|
527 | 524 | trackSimulationStateFromPayload({ |
528 | 525 | payload: emittedPayload, |
|
0 commit comments