@tellescope/chat 0.0.60 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/chat",
3
- "version": "0.0.60",
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.60",
37
- "@tellescope/react-components": "^0.0.60",
38
- "@tellescope/sdk": "^0.0.60",
39
- "@tellescope/types-client": "^0.0.60",
40
- "@tellescope/types-models": "^0.0.60",
41
- "@tellescope/types-utilities": "^0.0.60",
42
- "@tellescope/utilities": "^0.0.60",
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": "576d65bb0853dd189a81a4a5f463ed9ece05832d",
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,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
- {IN_REACT_WEB ? (
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
- <Typography>Attachments: {JSON.stringify(message.attachments, null, 2)}</Typography>
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
- {message.message && <Message key={message.id} message={message} {...messageStyles}/>}
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
  )}/>