@tellescope/chat 0.0.68 → 0.0.71

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.68",
3
+ "version": "0.0.71",
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.68",
37
- "@tellescope/react-components": "^0.0.68",
38
- "@tellescope/sdk": "^0.0.68",
39
- "@tellescope/types-client": "^0.0.68",
40
- "@tellescope/types-models": "^0.0.68",
41
- "@tellescope/types-utilities": "^0.0.68",
42
- "@tellescope/utilities": "^0.0.68",
36
+ "@tellescope/constants": "^0.0.71",
37
+ "@tellescope/react-components": "^0.0.71",
38
+ "@tellescope/sdk": "^0.0.71",
39
+ "@tellescope/types-client": "^0.0.71",
40
+ "@tellescope/types-models": "^0.0.71",
41
+ "@tellescope/types-utilities": "^0.0.71",
42
+ "@tellescope/utilities": "^0.0.71",
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": "6936c46e931a1e8a8c9bb3da746b66fc5d411448",
53
+ "gitHead": "5c1828fc4b49ea31050af77c820ca9f9fc6c6b58",
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  }
package/src/chat.tsx CHANGED
@@ -59,16 +59,8 @@ export {
59
59
 
60
60
  const MESSAGE_BORDER_RADIUS = 25
61
61
 
62
- const defaultSentContainerStyle: CSSProperties = {
63
- margin: 5,
64
- }
65
- const defaultReceivedContainerStyle: CSSProperties = {
66
- margin: 5,
67
- }
68
-
69
62
  const baseMessageStyle: CSSProperties = {
70
63
  borderRadius: MESSAGE_BORDER_RADIUS,
71
- maxWidth: '80%',
72
64
  paddingRight: 10,
73
65
  paddingLeft: 10,
74
66
  paddingTop: 6,
@@ -131,8 +123,6 @@ interface MessageProps extends MessageStyles {
131
123
  export const Message = ({
132
124
  message,
133
125
  iconSize=30,
134
- sentMessageContainerStyle=defaultSentContainerStyle,
135
- receivedMessageContainerStyle=defaultReceivedContainerStyle,
136
126
  sentMessageStyle=defaultSentStyle,
137
127
  receivedMessageStyle=defaultReceivedStyle,
138
128
  sentMessageTextStyle=defaultSentTextStyle,
@@ -144,15 +134,9 @@ export const Message = ({
144
134
  const [displayInfo] = useChatRoomDisplayInfo(message.roomId, session.type)
145
135
  const displayInfoLookup = value_is_loaded(displayInfo) ? displayInfo.value : {} as ChatRoomDisplayInfo
146
136
 
147
- const displayPicture = (
148
- <DisplayPicture
149
- user={displayInfoLookup[message.senderId ?? ''] ?? { id: message.senderId, avatar: '' }}
150
- size={iconSize} style={{ position: 'relative' }}
151
- />
152
- )
153
-
154
- const textBGStyle = message.senderId === chatUserId ? sentMessageStyle : receivedMessageStyle
155
- const textStyle = message.senderId === chatUserId ? sentMessageTextStyle : receivedMessageTextStyle
137
+ // deep copy so that the override of background color doesn't affect other messages
138
+ const textBGStyle = { ...message.senderId === chatUserId ? sentMessageStyle : receivedMessageStyle }
139
+ const textStyle = { ...message.senderId === chatUserId ? sentMessageTextStyle : receivedMessageTextStyle }
156
140
 
157
141
  if (!message.message) {
158
142
  textBGStyle.backgroundColor = undefined
@@ -170,8 +154,16 @@ export const Message = ({
170
154
  </Flex>
171
155
  )
172
156
 
157
+ const displayPicture = (
158
+ <DisplayPicture
159
+ style={{ maxWidth: '10%' }}
160
+ user={displayInfoLookup[message.senderId ?? ''] ?? { id: message.senderId, avatar: '' }}
161
+ size={iconSize}
162
+ />
163
+ )
164
+
173
165
  return (
174
- <Flex style={{ margin: 5 }}>
166
+ <Flex style={{ margin: 5, flexWrap: 'nowrap' }}>
175
167
  {message.senderId !== chatUserId && displayPicture}
176
168
  {messageComponent}
177
169
  {message.senderId === chatUserId && displayPicture}
@@ -185,9 +177,9 @@ export const MessageAttachments = ({ message, chatUserId, imageDimensions } : {
185
177
 
186
178
  return (
187
179
  <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} />
180
+ {message.attachments.filter(a => a.type === 'image').map(a=> (
181
+ <Flex key={a.secureName} style={{ margin: 10 }}>
182
+ <SecureImage key={a.secureName} secureName={a.secureName} alt="image attachment" {...imageDimensions} />
191
183
  </Flex>
192
184
  ))}
193
185
  </Flex>
@@ -215,9 +207,9 @@ export const Messages = ({
215
207
  <LoadingLinear data={messages} render={messages => (
216
208
  <Flex column flex={1}>
217
209
  {Header && <Header {...headerProps}/>}
218
- <List reverse style={style} items={messages} render={message => (
210
+ <List reverse style={style} items={messages} render={(message, i) => (
219
211
  <Flex column>
220
- <Message key={message.id} message={message} {...messageStyles} />
212
+ <Message message={message} {...messageStyles} />
221
213
  {!!message.attachments && message.attachments.length > 0 &&
222
214
  <MessageAttachments message={message} chatUserId={chatUserId} imageDimensions={imageDimensions} />
223
215
  }