@bcc-code/vue-bcc-chat-ui 3.40.1 → 3.41.0

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
@@ -2,7 +2,7 @@
2
2
  "name": "@bcc-code/vue-bcc-chat-ui",
3
3
  "author": "bcc-code",
4
4
  "license": "Apache-2.0",
5
- "version": "3.40.1",
5
+ "version": "3.41.0",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -8,16 +8,18 @@ import {
8
8
  provide,
9
9
  ref,
10
10
  watch,
11
+ watchEffect,
11
12
  } from "vue";
12
13
  import chat from "../chat";
13
14
  import { connect, disconnect } from "../chat/connection";
14
15
  import { loggedIn } from "../chat/login";
15
- import { Group } from "@cometchat/chat-sdk-javascript";
16
+ import { CometChat, Group, GroupMember } from "@cometchat/chat-sdk-javascript";
16
17
  import { watchAndApplyStyle } from "../chat/styleFix";
17
- import { ChatInstance } from "../chat/types";
18
+ import { ChatInstance, ParticipantInfo } from "../chat/types";
18
19
  import { CometChatMessageEvents, MessageStatus } from "@cometchat/uikit-resources";
19
20
  import BccChatMessages from "./BccChatMessages.vue";
20
21
  import BccScheduledMessages from "./BccScheduledMessages.vue";
22
+ import { getGroupMembersInfo } from "../chat/data";
21
23
  const props = defineProps({
22
24
  chatUid: { type: String, required: true },
23
25
  senderDisplayName: { type: String, required: false },
@@ -33,6 +35,9 @@ const componentId = ref(
33
35
  );
34
36
  const chatGroup = ref<Group>();
35
37
 
38
+ const emit = defineEmits(['groupMembersFetched']);
39
+ const groupMembers = ref<ParticipantInfo[]>();
40
+
36
41
  const chatInstance: Ref<ChatInstance> = ref({
37
42
  componentId: componentId,
38
43
  replyToMessage: null,
@@ -86,6 +91,8 @@ watch([loggedIn, () => props.chatUid, chat.initialized, () => props.groupMessage
86
91
  }
87
92
  }
88
93
  ])
94
+
95
+ getGroupMembersInfo(_chatUid).then((participants) => groupMembers.value = participants);
89
96
  }
90
97
 
91
98
  await chat.clearGroupChatCount(props.chatUid);
@@ -94,7 +101,13 @@ watch([loggedIn, () => props.chatUid, chat.initialized, () => props.groupMessage
94
101
  }
95
102
  }, { immediate: true });
96
103
 
97
-
104
+ watchEffect(() => {
105
+ if (groupMembers.value && groupMembers.value.length) {
106
+ emit('groupMembersFetched', groupMembers.value);
107
+ } else {
108
+ emit('groupMembersFetched', []);
109
+ }
110
+ })
98
111
 
99
112
  onMounted(() => {
100
113
  watchAndApplyStyle(".bcc-chat-message-list-wrapper", [
@@ -115,6 +128,30 @@ onMounted(() => {
115
128
  shadowDomSelector: "cometchat-preview",
116
129
  }
117
130
  ]);
131
+
132
+ CometChat.addGroupListener("groupListener", new CometChat.GroupListener({
133
+ onGroupMemberScopeChanged: (_action: any, changedUser: GroupMember, newScope: any, _oldScope: any, _changedGroup: GroupMember) => {
134
+ handleGroupMemberChanges(changedUser, "update", newScope);
135
+ },
136
+ onGroupMemberKicked: (_action: any, changedUser: GroupMember, _Ye: any, _group: any) => {
137
+ handleGroupMemberChanges(changedUser, "remove");
138
+ },
139
+ onGroupMemberBanned: (_action: any, user: GroupMember, _Ye: any, _group: any) => {
140
+ handleGroupMemberChanges(user, "remove");
141
+ },
142
+ onGroupMemberUnbanned: (_action: any, user: GroupMember, _Ye: any, _group: any) => {
143
+ handleGroupMemberChanges(user, "add");
144
+ },
145
+ onMemberAddedToGroup: (_action: any, user: GroupMember, _Ye: any, _group: any) => {
146
+ handleGroupMemberChanges(user, "add");
147
+ },
148
+ onGroupMemberLeft: (_action: any, user: GroupMember, _group: any) => {
149
+ handleGroupMemberChanges(user, "remove");
150
+ },
151
+ onGroupMemberJoined: (_action: any, user: GroupMember, _group: any) => {
152
+ handleGroupMemberChanges(user, "add");
153
+ }
154
+ }))
118
155
  });
119
156
 
120
157
  onBeforeUnmount(() => {
@@ -125,6 +162,31 @@ onUnmounted(async () => {
125
162
  await disconnect(componentId.value);
126
163
  });
127
164
 
165
+ function handleGroupMemberChanges(changedUser: GroupMember, action: string, newScope?: string) {
166
+ let participant: ParticipantInfo = {
167
+ uid: changedUser.getUid(),
168
+ displayName: changedUser.getName(),
169
+ avatar: changedUser.getAvatar(),
170
+ role: newScope ? newScope : CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT
171
+ }
172
+
173
+ if (action === "add" && !existsInGroup(changedUser.getUid())) {
174
+ groupMembers.value?.push(participant)
175
+ }
176
+
177
+ if (action === "remove" && existsInGroup(changedUser.getUid())) {
178
+ groupMembers.value = groupMembers.value?.filter(participant => participant.uid !== changedUser.getUid());
179
+ }
180
+
181
+ if (action === "update" && existsInGroup(changedUser.getUid())) {
182
+ groupMembers.value = groupMembers.value?.map(p => p.uid === changedUser.getUid() ? { ...p, ...participant } : p);
183
+ }
184
+ }
185
+
186
+ function existsInGroup(uid: string): boolean {
187
+ return groupMembers.value?.some(p => p.uid === uid) ?? false;
188
+ }
189
+
128
190
  function closeScheduledMessage() {
129
191
  chatInstance.value.captionedAttachment = null
130
192
  chatInstance.value.replyToMessage = null
@@ -144,8 +206,8 @@ function closeScheduledMessage() {
144
206
  <div>Connecting: {{chat.connecting.value}}</div>
145
207
  <div>CometChat: {{cometChatStatus}} <button @click="getCometChatStatus()">[refresh]</button></div>
146
208
  </div> -->
147
- <BccChatMessages v-if="chatGroup && !chatInstance.showScheduledMessagesChat" :chatGroup="chatGroup" :hide-deleted-messages="props.hideDeletedMessages"
148
- :chatUid="props.chatUid"></BccChatMessages>
209
+ <BccChatMessages v-if="chatGroup && !chatInstance.showScheduledMessagesChat" :chatGroup="chatGroup"
210
+ :hide-deleted-messages="props.hideDeletedMessages" :chatUid="props.chatUid"></BccChatMessages>
149
211
  <BccScheduledMessages v-else-if="chatGroup && chatInstance.showScheduledMessagesChat"
150
212
  class="bcc-scheduled-message-list" :chatGroup="chatInstance.scheduledMessageChat!"
151
213
  :originalChatUid="props.chatUid" @close="closeScheduledMessage()"></BccScheduledMessages>
@@ -165,11 +227,11 @@ function closeScheduledMessage() {
165
227
  body {
166
228
  background: #fff;
167
229
  color: #000;
230
+ }
168
231
 
169
- @media (prefers-color-scheme: dark) {
170
- background: #000;
171
- color: #fff;
172
- }
232
+ :host.dark body {
233
+ background: #000;
234
+ color: #fff;
173
235
  }
174
236
 
175
237
  .bcc-chat-message-list-wrapper {
@@ -189,7 +251,6 @@ accent900: text in avatar
189
251
  */
190
252
 
191
253
  .bcc-chat-message-list {
192
- height: 100%;
193
254
  --cc__primary: #cfeac8;
194
255
  --cc__primary150: #004e48;
195
256
  --cc__background: #f3faf7;
@@ -207,26 +268,30 @@ accent900: text in avatar
207
268
  --cc__accent900: #f3faf7;
208
269
  --cc__text-color: #000;
209
270
  --cc__link-color: #57639e;
271
+ }
210
272
 
211
- @media (prefers-color-scheme: dark) {
212
- --cc__primary: #57639e;
213
- --cc__primary150: #57639e;
214
- --cc__background: hsl(230, 25%, 15%);
215
- --cc__secondary: #111827;
216
- --cc__accent: #6274ae;
217
- --cc__accent50: rgba(98, 116, 174, 0.24);
218
- --cc__accent100: linear-gradient(45deg, #05070b 0%, #0c111c 100%);
219
- --cc__accent200: rgba(98, 116, 174, 0.35);
220
- --cc__accent300: rgba(98, 116, 174, 0.44);
221
- --cc__accent400: rgba(98, 116, 174, 0.53);
222
- --cc__accent500: rgba(98, 116, 174, 0.66);
223
- --cc__accent600: #758abc;
224
- --cc__accent700: #6274ae;
225
- --cc__accent800: rgba(98, 116, 174, 0.92);
226
- --cc__accent900: #f3faf7;
227
- --cc__text-color: #fff;
228
- --cc__link-color: #cfeac8;
229
- }
273
+ :root.dark .bcc-chat-message-list {
274
+ --cc__primary: #57639e;
275
+ --cc__primary150: #57639e;
276
+ --cc__background: hsl(230, 25%, 15%);
277
+ --cc__secondary: #111827;
278
+ --cc__accent: #6274ae;
279
+ --cc__accent50: rgba(98, 116, 174, 0.24);
280
+ --cc__accent100: linear-gradient(45deg, #05070b 0%, #0c111c 100%);
281
+ --cc__accent200: rgba(98, 116, 174, 0.35);
282
+ --cc__accent300: rgba(98, 116, 174, 0.44);
283
+ --cc__accent400: rgba(98, 116, 174, 0.53);
284
+ --cc__accent500: rgba(98, 116, 174, 0.66);
285
+ --cc__accent600: #758abc;
286
+ --cc__accent700: #6274ae;
287
+ --cc__accent800: rgba(98, 116, 174, 0.92);
288
+ --cc__accent900: #f3faf7;
289
+ --cc__text-color: #fff;
290
+ --cc__link-color: #cfeac8;
291
+ }
292
+
293
+ .bcc-chat-message-list {
294
+ height: 100%;
230
295
 
231
296
  /* 1. Wrapper for Messages component */
232
297
  .cc-messages-wrapper {
@@ -84,26 +84,26 @@ function scheduleMessage() {
84
84
  --cc__accent900: #f3faf7;
85
85
  --cc__text-color: #000;
86
86
  --cc__link-color: #57639e;
87
+ }
87
88
 
88
- @media (prefers-color-scheme: dark) {
89
- --cc__primary: #57639e;
90
- --cc__primary150: #57639e;
91
- --cc__background: hsl(230, 25%, 15%);
92
- --cc__secondary: #111827;
93
- --cc__accent: #6274ae;
94
- --cc__accent50: rgba(98, 116, 174, 0.24);
95
- --cc__accent100: linear-gradient(45deg, #05070b 0%, #0c111c 100%);
96
- --cc__accent200: rgba(98, 116, 174, 0.35);
97
- --cc__accent300: rgba(98, 116, 174, 0.44);
98
- --cc__accent400: rgba(98, 116, 174, 0.53);
99
- --cc__accent500: rgba(98, 116, 174, 0.66);
100
- --cc__accent600: #758abc;
101
- --cc__accent700: #6274ae;
102
- --cc__accent800: rgba(98, 116, 174, 0.92);
103
- --cc__accent900: #f3faf7;
104
- --cc__text-color: #fff;
105
- --cc__link-color: #cfeac8;
106
- }
89
+ :root.dark {
90
+ --cc__primary: #57639e;
91
+ --cc__primary150: #57639e;
92
+ --cc__background: hsl(230, 25%, 15%);
93
+ --cc__secondary: #111827;
94
+ --cc__accent: #6274ae;
95
+ --cc__accent50: rgba(98, 116, 174, 0.24);
96
+ --cc__accent100: linear-gradient(45deg, #05070b 0%, #0c111c 100%);
97
+ --cc__accent200: rgba(98, 116, 174, 0.35);
98
+ --cc__accent300: rgba(98, 116, 174, 0.44);
99
+ --cc__accent400: rgba(98, 116, 174, 0.53);
100
+ --cc__accent500: rgba(98, 116, 174, 0.66);
101
+ --cc__accent600: #758abc;
102
+ --cc__accent700: #6274ae;
103
+ --cc__accent800: rgba(98, 116, 174, 0.92);
104
+ --cc__accent900: #f3faf7;
105
+ --cc__text-color: #fff;
106
+ --cc__link-color: #cfeac8;
107
107
  }
108
108
 
109
109
  .modal {
@@ -74,7 +74,7 @@ onUnmounted(() => {
74
74
  <template>
75
75
  <div class="bcc-chat-message-list">
76
76
  <div class="title-bar">
77
- <p class="chatName"> {{ localize("SCHEDULED_MESSAGES") }} </p>
77
+ <p class="title"> {{ localize("SCHEDULED_MESSAGES") }} </p>
78
78
  <CloseIcon @click="closeList()" class="closeIcon" />
79
79
  </div>
80
80
  <div v-if="chatGroup" class="bcc-chat-message-list scheduled-list">
@@ -99,25 +99,21 @@ onUnmounted(() => {
99
99
  </div>
100
100
  </template>
101
101
 
102
- <style>
102
+ <style scoped>
103
103
  .title-bar {
104
104
  display: flex;
105
- background: var(--cc__accent200, #111827);
106
- min-height: 40px;
107
- padding: 5px;
105
+ align-items: center;
106
+ justify-content: space-between;
107
+ background: var(--cc__secondary, #111827);
108
+ padding: 0.4rem 0.6rem;
108
109
 
109
- .chatName {
110
- width: 92%;
111
- font-size: large;
112
- vertical-align: middle;
113
- margin-top: 4px;
114
- margin-left: 6px;
110
+
111
+ .title {
115
112
  color: var(--cc__text-color);
116
113
  }
117
114
 
118
115
  .closeIcon {
119
- max-height: 35px;
120
- width: 8%;
116
+ width: 1.2rem;
121
117
  cursor: pointer;
122
118
  color: var(--cc__text-color);
123
119
  }