Skip to content

Commit ac77e5b

Browse files
committed
chore(demo): fix types in websocketEventAutomation.ts
1 parent 81e3945 commit ac77e5b

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

examples/vite/src/AppSettings/ActionsMenu/WebSocketEventPromptDialog/websocketEventAutomation.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import type { Channel, StreamChat } from 'stream-chat';
1+
import type { Channel, Event, StreamChat } from 'stream-chat';
22

33
import {
4-
websocketEventTemplateDefinitions,
54
type SupportedWebsocketEventType,
65
type WebSocketEventTemplateContext,
6+
websocketEventTemplateDefinitions,
77
} from './websocketEventTemplates';
88
import type { SimulationState, SimulationUser } from './types';
99

1010
type JsonObject = Record<string, unknown>;
11-
type HandleEventArgument = Parameters<StreamChat['handleEvent']>[0];
1211

1312
const messageTextFragments = [
1413
'debug event payload',
@@ -454,7 +453,7 @@ export const trackSimulationStateFromPayload = ({
454453
simulationState,
455454
templateContext,
456455
}: {
457-
payload: JsonObject;
456+
payload: Event;
458457
simulationState: SimulationState;
459458
templateContext: WebSocketEventTemplateContext;
460459
}) => {
@@ -511,18 +510,16 @@ export const emitWebSocketEventPayload = ({
511510
}: {
512511
client: StreamChat;
513512
eventType: SupportedWebsocketEventType;
514-
payload: JsonObject;
513+
payload: Event;
515514
simulationState: SimulationState;
516515
templateContext: WebSocketEventTemplateContext;
517516
}) => {
518-
const emittedPayload = {
517+
const emittedPayload: Event = {
519518
...payload,
520519
type: eventType,
521520
};
522521

523-
client.handleEvent({
524-
data: JSON.stringify(emittedPayload),
525-
} as HandleEventArgument);
522+
client.dispatchEvent(emittedPayload);
526523

527524
trackSimulationStateFromPayload({
528525
payload: emittedPayload,

0 commit comments

Comments
 (0)