@bcc-code/vue-bcc-chat-ui 2.3.0 → 3.0.0-alpha.10

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": "2.3.0",
5
+ "version": "3.0.0-alpha.10",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -23,20 +23,20 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/markdown-it": "^13.0.7",
26
- "@types/node": "^20.11.25",
26
+ "@types/node": "^20.11.30",
27
27
  "@vitejs/plugin-vue": "^4.6.2",
28
28
  "path": "^0.12.7",
29
- "sass": "^1.71.1",
30
- "typescript": "^5.4.2",
31
- "vite": "^5.1.5",
29
+ "sass": "^1.72.0",
30
+ "typescript": "^5.4.3",
31
+ "vite": "^5.2.6",
32
32
  "vite-plugin-dts": "^3.7.3",
33
33
  "vue": "^3.4.21"
34
34
  },
35
35
  "dependencies": {
36
- "@cometchat/chat-sdk-javascript": "^4.0.3",
37
- "@cometchat/chat-uikit-vue": "^4.2.1",
38
- "@cometchat/uikit-resources": "^4.2.2",
39
- "@cometchat/uikit-shared": "^4.2.2",
36
+ "@cometchat/chat-sdk-javascript": "^4.0.4",
37
+ "@cometchat/chat-uikit-vue": "^4.3.1",
38
+ "@cometchat/uikit-resources": "^4.3.1",
39
+ "@cometchat/uikit-shared": "^4.3.2",
40
40
  "jwt-decode": "^4.0.0",
41
41
  "markdown-it": "^14.1.0"
42
42
  },
@@ -5,6 +5,7 @@ import {
5
5
  onUnmounted,
6
6
  ref,
7
7
  watch,
8
+ watchEffect,
8
9
  } from "vue";
9
10
  import chat from "../chat";
10
11
  import { connect, disconnect } from "../chat/connection";
@@ -12,9 +13,11 @@ import { loggedIn } from "../chat/login";
12
13
  import { CometChatMessages } from "@cometchat/chat-uikit-vue";
13
14
  import { Group } from "@cometchat/chat-sdk-javascript";
14
15
  import { watchAndApplyStyle } from "../chat/styleFix";
16
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
15
17
  import {
16
18
  messageComposerConfiguration,
17
19
  messageListConfiguration,
20
+ threadedMessagesConfiguration
18
21
  } from "../chat/uiKit";
19
22
 
20
23
  const props = defineProps({
@@ -35,13 +38,41 @@ watch([loggedIn, ()=>props.chatUid, chat.initialized], async ([_loggedIn, _chatU
35
38
  }
36
39
  }, { immediate: true });
37
40
 
38
- watch(chat.onlineStatus, async () => {
39
- await tryConnect(false);
41
+ watch(chat.onlineStatus, () => {
42
+ tryConnect(false);
40
43
  });
41
44
 
45
+ watch(chat.onlineMode, () => {
46
+ if (chat.onlineMode.value == 'online'){
47
+ tryConnect(true);
48
+ }
49
+ });
50
+
51
+ const showChat = ref(false);
52
+ watchEffect(() => {
53
+ if (chatGroup && (chat.connected.value || chat.onlineStatus.value == 'offline')){
54
+ showChat.value = true;
55
+ } else {
56
+ // This line is a trade-off.
57
+ // With it, the entire chat will be hidden and then reloaded when a connection is being established.
58
+ // The advantage is that the chat should then scroll to the latest message after reconnecting.
59
+ // Without it, the chat window won't reload. New messages should still be loaded, but the chat won't scroll down.
60
+ // The advantage with removing this line would be that half finished messages that were being composed when the user went offline
61
+ // wouldn't be lost...
62
+ showChat.value = false;
63
+ }
64
+ })
65
+
66
+ let _connecting = false;
42
67
  async function tryConnect(force: boolean) {
43
68
  if (chat.onlineStatus.value === "online" || force) {
44
- await connect(componentId.value);
69
+ console.log('CONNECTING::::');
70
+ if (!_connecting){
71
+ try {
72
+ await connect(componentId.value);
73
+ } catch { }
74
+ _connecting = false;
75
+ }
45
76
  }
46
77
  }
47
78
 
@@ -76,25 +107,23 @@ onMounted(() => {
76
107
  style: { 'flex-shrink': '0' },
77
108
  shadowDomSelector: "link-preview",
78
109
  },
79
- {
80
- selector: ".cc__messageinput",
81
- style: {
82
- "border-radius": "8px 8px 0 0",
83
- "box-shadow":
84
- "0px -1px 2px 0px rgba(17, 24, 39, 0.05), 1px -1px 3px 0px rgba(17, 24, 39, 0.1)",
85
- },
86
- shadowDomSelector: "cometchat-message-input",
87
- },
88
- {
89
- selector: ".cc__messageinput-input",
90
- style: {
91
- "font-size": "16px",
92
- padding: "8px",
93
- "max-height": "none",
94
- height: "64px",
95
- },
96
- shadowDomSelector: "cometchat-message-input",
97
- },
110
+ // {
111
+ // selector: ".messageinput",
112
+ // style: {
113
+ // "border-radius": "8px 8px 0 0",
114
+ // "box-shadow":
115
+ // "0px -1px 2px 0px rgba(17, 24, 39, 0.05), 1px -1px 3px 0px rgba(17, 24, 39, 0.1)",
116
+ // },
117
+ // },
118
+ // {
119
+ // selector: ".messageinput-input",
120
+ // style: {
121
+ // "font-size": "16px",
122
+ // padding: "8px",
123
+ // "max-height": "none",
124
+ // height: "64px",
125
+ // },
126
+ // },
98
127
  ]);
99
128
  });
100
129
 
@@ -102,26 +131,49 @@ onUnmounted(async () => {
102
131
  await disconnect(componentId.value);
103
132
  });
104
133
 
134
+ const cometChatStatus = ref('');
135
+ function getCometChatStatus(){
136
+ cometChatStatus.value = new Date().getTime() + CometChat.getConnectionStatus();
137
+ }
138
+
105
139
  </script>
106
140
 
107
141
  <template>
108
142
  <div class="bcc-chat-message-list-wrapper">
109
- <div v-if="chatGroup && (chat.connected.value || chat.onlineStatus.value === 'offline')" class="bcc-chat-message-list">
110
- <CometChatMessages
143
+ <div>
144
+ <div>Connecting... <button @click="tryConnect(true)">[retry]</button></div>
145
+ <div>Online status: {{chat.onlineStatus}}</div>
146
+ <div>Online mode: {{chat.onlineMode}}</div>
147
+ <div>Connected: {{chat.connected.value}}</div>
148
+ <div>Connecting: {{chat.connecting.value}}</div>
149
+ <div>CometChat: {{cometChatStatus}} <button @click="getCometChatStatus()">[refresh]</button></div>
150
+ </div>
151
+ <div v-if="showChat" class="bcc-chat-message-list">
152
+
153
+ <CometChatMessages
111
154
  :hideMessageHeader="true"
112
155
  :disableSoundForMessages="true"
113
156
  :messageComposerConfiguration="messageComposerConfiguration"
114
157
  :messageListConfiguration="messageListConfiguration"
158
+ :threadedMessagesConfiguration="threadedMessagesConfiguration"
115
159
  :hideMessageComposer="false"
116
160
  :hideDetails="true"
117
161
  :group="chatGroup"
118
162
  />
163
+
119
164
  <div v-if="chat.onlineStatus.value === 'offline' || !chat.connected.value" class="bcc-chat-message-composer-offline">
120
- <span>Waiting for connection...</span>
165
+ <span v-if="chat.onlineStatus.value === 'offline'">Waiting for network...</span>
166
+ <span v-else>Connecting...</span>
121
167
  </div>
122
168
  </div>
123
- <div class="bcc-chat-message-list-offline">
124
- <span>Waiting for connection...</span>
169
+ <div v-else-if="!chat.connected.value" class="bcc-chat-message-list-offline">
170
+ <span>Connecting... <button @click="tryConnect(true)">[retry]</button></span>
171
+ </div>
172
+ <div v-else-if="!chatGroup" class="bcc-chat-message-list-offline">
173
+ <span>Loading chat...</span>
174
+ </div>
175
+ <div v-else class="bcc-chat-message-list-offline">
176
+ <span>Loading...</span>
125
177
  </div>
126
178
  </div>
127
179
  </template>
@@ -202,11 +254,15 @@ accent900: text in avatar
202
254
 
203
255
  /* 1.1.2 Wrapper for Messages Composer */
204
256
  .cc-messagecomposer-wrapper {
205
- padding: 0;
257
+ //padding: 0; //Use to remove side padding on composer
206
258
  }
207
259
  }
208
260
  }
209
261
 
262
+ .cc-messagebubble-wrapper__container {
263
+ max-width: 80%;
264
+ }
265
+
210
266
  .cc-messagebubble-wrapper__messageoptions {
211
267
  border-radius: 8px;
212
268
  .cc-context-menu__top-menu {
@@ -246,7 +302,6 @@ accent900: text in avatar
246
302
  align-items: center;
247
303
  font: 700 22px sans-serif;
248
304
  color: #bcbcbc;
249
- z-index: -1;
250
305
  }
251
306
 
252
307
  .cc-messagecomposer__emojikeyboard {