@tellescope/chat 0.0.60 → 0.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/chat.d.ts +7 -4
- package/lib/cjs/chat.d.ts.map +1 -1
- package/lib/cjs/chat.js +14 -7
- package/lib/cjs/chat.js.map +1 -1
- package/lib/esm/chat.d.ts +7 -4
- package/lib/esm/chat.d.ts.map +1 -1
- package/lib/esm/chat.js +15 -8
- package/lib/esm/chat.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/chat.tsx +35 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.63",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"@fontsource/roboto": "^4.5.1",
|
|
34
34
|
"@mui/icons-material": "^5.0.1",
|
|
35
35
|
"@mui/material": "^5.0.2",
|
|
36
|
-
"@tellescope/constants": "^0.0.
|
|
37
|
-
"@tellescope/react-components": "^0.0.
|
|
38
|
-
"@tellescope/sdk": "^0.0.
|
|
39
|
-
"@tellescope/types-client": "^0.0.
|
|
40
|
-
"@tellescope/types-models": "^0.0.
|
|
41
|
-
"@tellescope/types-utilities": "^0.0.
|
|
42
|
-
"@tellescope/utilities": "^0.0.
|
|
36
|
+
"@tellescope/constants": "^0.0.63",
|
|
37
|
+
"@tellescope/react-components": "^0.0.63",
|
|
38
|
+
"@tellescope/sdk": "^0.0.63",
|
|
39
|
+
"@tellescope/types-client": "^0.0.63",
|
|
40
|
+
"@tellescope/types-models": "^0.0.63",
|
|
41
|
+
"@tellescope/types-utilities": "^0.0.63",
|
|
42
|
+
"@tellescope/utilities": "^0.0.63",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
44
44
|
"@typescript-eslint/parser": "^4.33.0",
|
|
45
45
|
"eslint": "^7.32.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"react": "^17.0.2",
|
|
51
51
|
"react-dom": "^17.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "dd5cba147f2f4100ce33ee1760fb8519863e656a",
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
}
|
package/src/chat.tsx
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
useChats,
|
|
21
21
|
useChatRoomDisplayInfo,
|
|
22
22
|
ChatRoomDisplayInfo,
|
|
23
|
+
SecureImage,
|
|
24
|
+
ImageDimensions,
|
|
23
25
|
} from "@tellescope/react-components"
|
|
24
26
|
|
|
25
27
|
import {
|
|
@@ -152,29 +154,43 @@ export const Message = ({
|
|
|
152
154
|
const textBGStyle = message.senderId === chatUserId ? sentMessageStyle : receivedMessageStyle
|
|
153
155
|
const textStyle = message.senderId === chatUserId ? sentMessageTextStyle : receivedMessageTextStyle
|
|
154
156
|
|
|
157
|
+
if (!message.message) {
|
|
158
|
+
textBGStyle.backgroundColor = undefined
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const messageComponent = IN_REACT_WEB ? (
|
|
162
|
+
<Typography component="div" style={{ ...textStyle, ...textBGStyle }}>
|
|
163
|
+
{message.message}
|
|
164
|
+
</Typography>
|
|
165
|
+
) : (
|
|
166
|
+
<Flex style={{ ...textBGStyle }}>
|
|
167
|
+
<Typography component="div" style={{ ...textStyle }}>
|
|
168
|
+
{message.message}
|
|
169
|
+
</Typography>
|
|
170
|
+
</Flex>
|
|
171
|
+
)
|
|
172
|
+
|
|
155
173
|
return (
|
|
156
174
|
<Flex style={{ margin: 5 }}>
|
|
157
175
|
{message.senderId !== chatUserId && displayPicture}
|
|
158
|
-
{
|
|
159
|
-
<Typography component="div" style={{ ...textStyle, ...textBGStyle }}>
|
|
160
|
-
{message.message}
|
|
161
|
-
</Typography>
|
|
162
|
-
)
|
|
163
|
-
: (
|
|
164
|
-
<Flex style={{ ...textBGStyle }}>
|
|
165
|
-
<Typography component="div" style={{ ...textStyle }}>
|
|
166
|
-
{message.message}
|
|
167
|
-
</Typography>
|
|
168
|
-
</Flex>
|
|
169
|
-
)}
|
|
176
|
+
{messageComponent}
|
|
170
177
|
{message.senderId === chatUserId && displayPicture}
|
|
171
178
|
</Flex>
|
|
172
179
|
)
|
|
173
180
|
}
|
|
174
181
|
|
|
175
|
-
export const MessageAttachments = ({ message } : { message: ChatMessage }) => {
|
|
182
|
+
export const MessageAttachments = ({ message, chatUserId, imageDimensions } : { message: ChatMessage, chatUserId: string, imageDimensions?: ImageDimensions }) => {
|
|
183
|
+
if (!message.attachments) return null
|
|
184
|
+
if (message.attachments.length === 0) return null
|
|
185
|
+
|
|
176
186
|
return (
|
|
177
|
-
<
|
|
187
|
+
<Flex column alignSelf={message.senderId === chatUserId ? "flex-end" : "flex-start"}>
|
|
188
|
+
{message.attachments.filter(a => a.type === 'image').map(a => (
|
|
189
|
+
<Flex style={{ margin: 10 }}>
|
|
190
|
+
<SecureImage key={a.secureName} secureName={a.secureName} alt="image attachment" {...imageDimensions} />
|
|
191
|
+
</Flex>
|
|
192
|
+
))}
|
|
193
|
+
</Flex>
|
|
178
194
|
)
|
|
179
195
|
}
|
|
180
196
|
|
|
@@ -184,6 +200,7 @@ interface Messages_T extends MessageStyles {
|
|
|
184
200
|
chatUserId: string,
|
|
185
201
|
Header?: React.JSXElementConstructor<MessagesHeaderProps>,
|
|
186
202
|
headerProps?: MessagesHeaderProps,
|
|
203
|
+
imageDimensions?: ImageDimensions,
|
|
187
204
|
}
|
|
188
205
|
export const Messages = ({
|
|
189
206
|
resolveSenderName,
|
|
@@ -192,6 +209,7 @@ export const Messages = ({
|
|
|
192
209
|
Header=MessagesHeader,
|
|
193
210
|
headerProps,
|
|
194
211
|
style,
|
|
212
|
+
imageDimensions,
|
|
195
213
|
...messageStyles
|
|
196
214
|
}: Messages_T & Styled) => (
|
|
197
215
|
<LoadingLinear data={messages} render={messages => (
|
|
@@ -199,9 +217,9 @@ export const Messages = ({
|
|
|
199
217
|
{Header && <Header {...headerProps}/>}
|
|
200
218
|
<List reverse style={style} items={messages} render={message => (
|
|
201
219
|
<Flex column>
|
|
202
|
-
|
|
203
|
-
{message.attachments && message.attachments.length > 0 &&
|
|
204
|
-
<MessageAttachments message={message} />
|
|
220
|
+
<Message key={message.id} message={message} {...messageStyles} />
|
|
221
|
+
{!!message.attachments && message.attachments.length > 0 &&
|
|
222
|
+
<MessageAttachments message={message} chatUserId={chatUserId} imageDimensions={imageDimensions} />
|
|
205
223
|
}
|
|
206
224
|
</Flex>
|
|
207
225
|
)}/>
|