@tellescope/chat 0.0.58 → 0.0.61
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 +8 -2
- package/lib/cjs/chat.d.ts.map +1 -1
- package/lib/cjs/chat.js +18 -5
- package/lib/cjs/chat.js.map +1 -1
- package/lib/esm/chat.d.ts +8 -2
- package/lib/esm/chat.d.ts.map +1 -1
- package/lib/esm/chat.js +17 -5
- package/lib/esm/chat.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/chat.tsx +42 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.61",
|
|
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.61",
|
|
37
|
+
"@tellescope/react-components": "^0.0.61",
|
|
38
|
+
"@tellescope/sdk": "^0.0.61",
|
|
39
|
+
"@tellescope/types-client": "^0.0.61",
|
|
40
|
+
"@tellescope/types-models": "^0.0.61",
|
|
41
|
+
"@tellescope/types-utilities": "^0.0.61",
|
|
42
|
+
"@tellescope/utilities": "^0.0.61",
|
|
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": "6ece184f7d132d52dc5b702febde55a6bd86446b",
|
|
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,32 +154,53 @@ 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
|
|
|
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
|
+
|
|
186
|
+
return (
|
|
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>
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
|
|
175
197
|
interface Messages_T extends MessageStyles {
|
|
176
198
|
resolveSenderName?: (room: ChatRoom) => React.ReactNode;
|
|
177
199
|
messages: LoadedData<ChatMessage[]>,
|
|
178
200
|
chatUserId: string,
|
|
179
201
|
Header?: React.JSXElementConstructor<MessagesHeaderProps>,
|
|
180
202
|
headerProps?: MessagesHeaderProps,
|
|
203
|
+
imageDimensions?: ImageDimensions,
|
|
181
204
|
}
|
|
182
205
|
export const Messages = ({
|
|
183
206
|
resolveSenderName,
|
|
@@ -186,13 +209,19 @@ export const Messages = ({
|
|
|
186
209
|
Header=MessagesHeader,
|
|
187
210
|
headerProps,
|
|
188
211
|
style,
|
|
212
|
+
imageDimensions,
|
|
189
213
|
...messageStyles
|
|
190
214
|
}: Messages_T & Styled) => (
|
|
191
215
|
<LoadingLinear data={messages} render={messages => (
|
|
192
216
|
<Flex column flex={1}>
|
|
193
217
|
{Header && <Header {...headerProps}/>}
|
|
194
218
|
<List reverse style={style} items={messages} render={message => (
|
|
195
|
-
<
|
|
219
|
+
<Flex column>
|
|
220
|
+
<Message key={message.id} message={message} {...messageStyles} />
|
|
221
|
+
{!!message.attachments && message.attachments.length > 0 &&
|
|
222
|
+
<MessageAttachments message={message} chatUserId={chatUserId} imageDimensions={imageDimensions} />
|
|
223
|
+
}
|
|
224
|
+
</Flex>
|
|
196
225
|
)}/>
|
|
197
226
|
</Flex>
|
|
198
227
|
)}/>
|