Skip to content

Commit 873281b

Browse files
Merge pull request #95 from cometchat-pro/v3
V3
2 parents fbb25ba + 4df23a8 commit 873281b

File tree

11 files changed

+63
-97
lines changed

11 files changed

+63
-97
lines changed

CometChatWorkspace/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CometChatWorkspace/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "cometchat-pro-react-ui-kit",
3-
"version": "3.0.2-beta1-1",
3+
"version": "3.0.5-1",
44
"description": "CometChat UI Kit for React App",
55
"author": "CometChat",
66
"dependencies": {
77
"react": "^17.0.2",
88
"react-dom": "^17.0.2",
99
"react-scripts": "^4.0.3",
10-
"@cometchat-pro/chat": "3.0.2-beta1",
10+
"@cometchat-pro/chat": "3.0.5",
1111
"@emotion/core": "^10.0.35",
1212
"dateformat": "^4.0.0",
1313
"emoji-mart": "^3.0.0",

CometChatWorkspace/src/components/Chats/CometChatConversationList/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class CometChatConversationList extends React.Component {
291291
//if chat window is not open, mark message as delivered
292292
if ((this.getContext().type === "" || Object.keys(this.getContext().item).length === 0)
293293
&& message.hasOwnProperty("deliveredAt") === false) {
294-
CometChat.markAsDelivered(message);
294+
CometChat.markAsDelivered(message).catch(error => {});
295295
}
296296
};
297297

CometChatWorkspace/src/components/Groups/CometChatGroupList/index.js

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,8 @@ class CometChatGroupList extends React.PureComponent {
185185
this.updateMemberRemoved(group, options);
186186
break;
187187
case enums.GROUP_MEMBER_ADDED:
188-
this.updateMemberAdded(group, options);
189-
break;
190188
case enums.GROUP_MEMBER_JOINED:
191-
this.updateMemberJoined(group, options);
189+
this.updateMemberAddition(group, options);
192190
break;
193191
default:
194192
break;
@@ -223,70 +221,32 @@ class CometChatGroupList extends React.PureComponent {
223221
}
224222
};
225223

226-
updateMemberAdded = (group, options) => {
224+
// Callback for when group member is added or joined
225+
updateMemberAddition = (group, options) => {
227226
let grouplist = [...this.state.grouplist];
228227

229228
//search for group
230229
let groupKey = grouplist.findIndex(g => g.guid === group.guid);
231230

232231
if (groupKey > -1) {
232+
if (options && this.loggedInUser.uid === options.user.uid){
233233
let groupObj = {...grouplist[groupKey]};
234-
235-
let membersCount = parseInt(group.membersCount);
236-
237-
let scope = group.hasOwnProperty("scope") ? group.scope : "";
238-
let hasJoined = group.hasOwnProperty("hasJoined") ? group.hasJoined : false;
239-
240-
if (options && this.loggedInUser.uid === options.user.uid) {
241-
scope = CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT;
242-
hasJoined = true;
243-
}
244-
245-
let newgroupObj = Object.assign({}, groupObj, {membersCount: membersCount, scope: scope, hasJoined: hasJoined});
234+
let hasJoined = true;
235+
let newgroupObj = Object.assign({}, groupObj, { hasJoined: hasJoined});
246236

247237
grouplist.splice(groupKey, 1, newgroupObj);
248238
this.setState({grouplist: grouplist});
249239
} else {
250-
let groupObj = {...group};
251-
252-
let scope = groupObj.hasOwnProperty("scope") ? groupObj.scope : "";
253-
let hasJoined = groupObj.hasOwnProperty("hasJoined") ? groupObj.hasJoined : false;
240+
let groupObj = {...grouplist[groupKey]};
254241
let membersCount = parseInt(groupObj.membersCount);
255242

256-
if (options && this.loggedInUser.uid === options.user.uid) {
257-
scope = CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT;
258-
hasJoined = true;
259-
}
260-
261-
let newgroupObj = Object.assign({}, groupObj, {membersCount: membersCount, scope: scope, hasJoined: hasJoined});
262-
263-
grouplist.unshift(newgroupObj);
264-
this.setState({grouplist: grouplist});
243+
let newgroupObj = Object.assign({},groupObj, {membersCount: membersCount});
244+
grouplist.splice(groupKey, 1, newgroupObj);
245+
this.setState({grouplist:grouplist});
265246
}
266-
};
267247

268-
updateMemberJoined = (group, options) => {
269-
let grouplist = [...this.state.grouplist];
270-
271-
//search for group
272-
let groupKey = grouplist.findIndex(g => g.guid === group.guid);
273-
274-
if (groupKey > -1) {
275-
let groupObj = {...grouplist[groupKey]};
276-
277-
let scope = groupObj.scope;
278-
let membersCount = parseInt(group.membersCount);
279-
280-
if (options && this.loggedInUser.uid === options.user.uid) {
281-
scope = CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT;
282-
}
283-
284-
let newgroupObj = Object.assign({}, groupObj, {membersCount: membersCount, scope: scope});
285-
286-
grouplist.splice(groupKey, 1, newgroupObj);
287-
this.setState({grouplist: grouplist});
288248
}
289-
};
249+
};
290250

291251
updateMemberChanged = (group, options) => {
292252
let grouplist = [...this.state.grouplist];

CometChatWorkspace/src/components/Messages/CometChatMessageList/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class CometChatMessageList extends React.PureComponent {
171171

172172
//mark the message as read
173173
if (message.hasOwnProperty("readAt") === false) {
174-
CometChat.markAsRead(message);
174+
CometChat.markAsRead(message).catch(error => {});
175175
this.props.actionGenerated(enums.ACTIONS["MESSAGE_READ"], message);
176176
}
177177
}
@@ -343,13 +343,13 @@ class CometChatMessageList extends React.PureComponent {
343343
markMessageAsDelivered = message => {
344344

345345
if (message.sender?.uid !== this.state.loggedInUser?.uid && message.hasOwnProperty("deliveredAt") === false) {
346-
CometChat.markAsDelivered(message);
346+
CometChat.markAsDelivered(message).catch(error => {});
347347
}
348348
};
349349

350350
markMessageAsRead = (message, type) => {
351351
if (message.hasOwnProperty("readAt") === false) {
352-
CometChat.markAsRead(message);
352+
CometChat.markAsRead(message).catch(error => {});
353353
}
354354
};
355355

CometChatWorkspace/src/components/Messages/CometChatMessages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ class CometChatMessages extends React.PureComponent {
10341034
messageComposer = null;
10351035
}
10361036

1037-
if (this.getContext().type === CometChat.RECEIVER_TYPE.USER && Object.keys(this.getContext().item).length && this.getContext().item.blockedByMe) {
1037+
if (this.getContext()?.type === CometChat.RECEIVER_TYPE.USER && Object.keys(this.getContext().item).length && this.getContext().item.blockedByMe) {
10381038
messageComposer = null;
10391039
messageList = null;
10401040
blockedUser = <CometChatBlockedUser user={this.item} />;

CometChatWorkspace/src/components/Messages/Extensions/CometChatReceiverPollMessageBubble/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class CometChatReceiverPollMessageBubble extends React.Component {
158158
}
159159

160160
let checkIcon = null;
161-
if (optionData.hasOwnProperty("voters") && optionData.voters.hasOwnProperty(this.loggedInUser?.uid)) {
161+
if (optionData.hasOwnProperty("voters") && optionData.voters.hasOwnProperty(this.state.loggedInUser?.uid)) {
162162
checkIcon = <i css={checkIconStyle(checkImg, this.context)}></i>;
163163
}
164164

CometChatWorkspace/src/components/Messages/Extensions/CometChatReceiverPollMessageBubble/style.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
export const messageContainerStyle = () => {
23

34
return {
@@ -17,7 +18,7 @@ export const messageContainerStyle = () => {
1718
export const messageWrapperStyle = () => {
1819

1920
return {
20-
width: "auto",
21+
width: "100%",
2122
flex: "1 1",
2223
alignSelf: "flex-start",
2324
display: "flex",
@@ -41,6 +42,7 @@ export const messageDetailStyle = () => {
4142
flex: "1 1",
4243
display: "flex",
4344
flexDirection: "column",
45+
width: "calc(100% - 36px)",
4446
}
4547
}
4648

@@ -150,7 +152,7 @@ export const answerWrapperStyle = (state, optionData, context) => {
150152
let widthProp = "calc(100% - 40px)";
151153
if (optionData.hasOwnProperty("voters") && optionData.voters.hasOwnProperty(state?.loggedInUser?.uid)) {
152154
//countPadding = "0px 8px";
153-
widthProp = "calc(100% - 40px)";
155+
widthProp = "calc(100% - 80px)";
154156
}
155157

156158
return {
@@ -159,7 +161,7 @@ export const answerWrapperStyle = (state, optionData, context) => {
159161
display: "flex",
160162
alignItems: "center",
161163
minHeight: "35px",
162-
padding: "0 16px",
164+
padding: "0 16px",
163165
height: "100%",
164166
zIndex: "2",
165167
p: {
@@ -170,7 +172,7 @@ export const answerWrapperStyle = (state, optionData, context) => {
170172
fontSize: "14px",
171173
},
172174
span: {
173-
maxWidth: "40px",
175+
width: "40px",
174176
padding: countPadding,
175177
fontWeight: "bold",
176178
display: "inline-block",
@@ -182,7 +184,7 @@ export const answerWrapperStyle = (state, optionData, context) => {
182184
export const checkIconStyle = (img, context) => {
183185

184186
return {
185-
width: "24px",
187+
width: "40px",
186188
height: "24px",
187189
mask: `url(${img}) center center no-repeat`,
188190
backgroundColor: `${context.theme.secondaryTextColor}`,
@@ -211,4 +213,4 @@ export const messageReactionsWrapperStyle = () => {
211213
justifyContent: "flex-start",
212214
minHeight: "36px",
213215
}
214-
}
216+
}

0 commit comments

Comments
 (0)