Skip to content

Commit ffaedf9

Browse files
authored
Follow Up to addressing #1258 comments (#1260)
* fix Conversations Types
1 parent fe6da8f commit ffaedf9

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

packages/client/src/fabric/Conversation.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ const isConversationChatEventParams = (
4747
typeof event === 'object' &&
4848
event !== null &&
4949
'subtype' in event &&
50-
event.subtype === 'chat' &&
51-
'user_name' in event &&
52-
'text' in event
50+
event.subtype === 'chat'
5351
)
5452
}
5553

@@ -103,7 +101,7 @@ export class Conversation {
103101
if (chatCallbacks?.size) {
104102
// the backend includes the user_name if is chat event
105103
chatCallbacks.forEach((cb) =>
106-
cb(event as unknown as ConversationChatEventParams)
104+
cb(event)
107105
)
108106
}
109107
}
@@ -180,8 +178,7 @@ export class Conversation {
180178
await this.httpClient.fetch<GetConversationMessagesResponse>(
181179
makeQueryParamsUrls(path, queryParams)
182180
)
183-
184-
181+
185182
return buildPaginatedResult<ConversationMessage>(
186183
body,
187184
this.httpClient.fetch

packages/core/src/types/conversation.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ export interface ConversationMessageEventParams {
99
id: string
1010
kind?: string
1111
metadata: Record<string, unknown>
12-
subtype: string
13-
text?: string
12+
subtype: 'chat' | 'update'
13+
text: string | null
1414
ts: number
1515
type: string
1616
from_address_id: string
17+
user_name: string
1718
}
1819

1920
export type ConversationChatMessageEventParams = Omit<
2021
ConversationMessageEventParams,
21-
'kind' | 'hidden' | 'metadata'
22+
'kind'
2223
> & {
2324
text: string
2425
user_name: string
26+
subtype: 'chat'
2527
}
2628

2729
export interface ConversationMessageEvent extends SwEvent {

0 commit comments

Comments
 (0)