Skip to content

Commit 635abd9

Browse files
committed
Update types
1 parent f6445f4 commit 635abd9

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@flyerhq/react-native-chat-ui",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "Actively maintained, community-driven chat UI implementation with an optional Firebase BaaS.",
55
"homepage": "https://flyer.chat",
66
"main": "lib/index.js",

src/components/Chat/__tests__/Chat.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('chat', () => {
6363
)
6464
const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel)
6565
fireEvent.press(button)
66-
expect(onSendPress).toHaveBeenCalledWith({ text: 'text' })
66+
expect(onSendPress).toHaveBeenCalledWith({ text: 'text', type: 'text' })
6767
})
6868

6969
it('opens file on a file message tap', () => {

src/components/Input/Input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const Input = ({
7272
// Additional check for the keyboard input.
7373
/* istanbul ignore next */
7474
if (trimmedValue) {
75-
onSendPress({ text: trimmedValue })
75+
onSendPress({ text: trimmedValue, type: 'text' })
7676
setText('')
7777
}
7878
}

src/components/Input/__tests__/Input.test.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('input', () => {
2828
fireEvent.changeText(textInput, 'text')
2929
const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel)
3030
fireEvent.press(button)
31-
expect(onSendPress).toHaveBeenCalledWith({ text: 'text' })
31+
expect(onSendPress).toHaveBeenCalledWith({ text: 'text', type: 'text' })
3232
expect(textInput.props).toHaveProperty('value', '')
3333
})
3434

@@ -66,7 +66,7 @@ describe('input', () => {
6666
fireEvent.changeText(textInput, 'text')
6767
const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel)
6868
fireEvent.press(button)
69-
expect(onSendPress).toHaveBeenCalledWith({ text: 'text' })
69+
expect(onSendPress).toHaveBeenCalledWith({ text: 'text', type: 'text' })
7070
expect(textInput.props).toHaveProperty('value', 'text')
7171
})
7272

@@ -90,7 +90,7 @@ describe('input', () => {
9090
fireEvent.changeText(textInput, 'text')
9191
const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel)
9292
fireEvent.press(button)
93-
expect(onSendPress).toHaveBeenCalledWith({ text: 'text' })
93+
expect(onSendPress).toHaveBeenCalledWith({ text: 'text', type: 'text' })
9494
expect(textInput.props).toHaveProperty('value', '')
9595
})
9696

@@ -114,7 +114,7 @@ describe('input', () => {
114114
fireEvent.changeText(textInput, 'text')
115115
const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel)
116116
fireEvent.press(button)
117-
expect(onSendPress).toHaveBeenCalledWith({ text: value })
117+
expect(onSendPress).toHaveBeenCalledWith({ text: value, type: 'text' })
118118
expect(textInput.props).toHaveProperty('value', value)
119119
})
120120

@@ -137,7 +137,10 @@ describe('input', () => {
137137
const textInput = getByPlaceholderText(l10n.en.inputPlaceholder)
138138
const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel)
139139
fireEvent.press(button)
140-
expect(onSendPress).toHaveBeenCalledWith({ text: defaultValue })
140+
expect(onSendPress).toHaveBeenCalledWith({
141+
text: defaultValue,
142+
type: 'text',
143+
})
141144
expect(textInput.props).toHaveProperty('value', '')
142145
})
143146

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export namespace MessageType {
6060

6161
export interface PartialCustom extends Base {
6262
metadata?: Record<string, any>
63+
type: 'custom'
6364
}
6465

6566
export interface Custom extends Base, PartialCustom {
@@ -71,6 +72,7 @@ export namespace MessageType {
7172
mimeType?: string
7273
name: string
7374
size: number
75+
type: 'file'
7476
uri: string
7577
}
7678

@@ -83,6 +85,7 @@ export namespace MessageType {
8385
metadata?: Record<string, any>
8486
name: string
8587
size: number
88+
type: 'image'
8689
uri: string
8790
width?: number
8891
}
@@ -95,6 +98,7 @@ export namespace MessageType {
9598
metadata?: Record<string, any>
9699
previewData?: PreviewData
97100
text: string
101+
type: 'text'
98102
}
99103

100104
export interface Text extends Base, PartialText {

0 commit comments

Comments
 (0)