@bcc-code/vue-bcc-chat-ui 3.0.0-alpha.1 → 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": "3.0.0-alpha.1",
5
+ "version": "3.0.0-alpha.10",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -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,23 +107,23 @@ onMounted(() => {
76
107
  style: { 'flex-shrink': '0' },
77
108
  shadowDomSelector: "link-preview",
78
109
  },
79
- {
80
- selector: ".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
- },
87
- {
88
- selector: ".messageinput-input",
89
- style: {
90
- "font-size": "16px",
91
- padding: "8px",
92
- "max-height": "none",
93
- height: "64px",
94
- },
95
- },
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
+ // },
96
127
  ]);
97
128
  });
98
129
 
@@ -100,26 +131,49 @@ onUnmounted(async () => {
100
131
  await disconnect(componentId.value);
101
132
  });
102
133
 
134
+ const cometChatStatus = ref('');
135
+ function getCometChatStatus(){
136
+ cometChatStatus.value = new Date().getTime() + CometChat.getConnectionStatus();
137
+ }
138
+
103
139
  </script>
104
140
 
105
141
  <template>
106
142
  <div class="bcc-chat-message-list-wrapper">
107
- <div v-if="chatGroup && (chat.connected.value || chat.onlineStatus.value === 'offline')" class="bcc-chat-message-list">
108
- <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
109
154
  :hideMessageHeader="true"
110
155
  :disableSoundForMessages="true"
111
156
  :messageComposerConfiguration="messageComposerConfiguration"
112
157
  :messageListConfiguration="messageListConfiguration"
158
+ :threadedMessagesConfiguration="threadedMessagesConfiguration"
113
159
  :hideMessageComposer="false"
114
160
  :hideDetails="true"
115
161
  :group="chatGroup"
116
162
  />
163
+
117
164
  <div v-if="chat.onlineStatus.value === 'offline' || !chat.connected.value" class="bcc-chat-message-composer-offline">
118
- <span>Waiting for connection...</span>
165
+ <span v-if="chat.onlineStatus.value === 'offline'">Waiting for network...</span>
166
+ <span v-else>Connecting...</span>
119
167
  </div>
120
168
  </div>
121
- <div class="bcc-chat-message-list-offline">
122
- <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>
123
177
  </div>
124
178
  </div>
125
179
  </template>
@@ -200,11 +254,15 @@ accent900: text in avatar
200
254
 
201
255
  /* 1.1.2 Wrapper for Messages Composer */
202
256
  .cc-messagecomposer-wrapper {
203
- padding: 0;
257
+ //padding: 0; //Use to remove side padding on composer
204
258
  }
205
259
  }
206
260
  }
207
261
 
262
+ .cc-messagebubble-wrapper__container {
263
+ max-width: 80%;
264
+ }
265
+
208
266
  .cc-messagebubble-wrapper__messageoptions {
209
267
  border-radius: 8px;
210
268
  .cc-context-menu__top-menu {
@@ -244,7 +302,6 @@ accent900: text in avatar
244
302
  align-items: center;
245
303
  font: 700 22px sans-serif;
246
304
  color: #bcbcbc;
247
- z-index: -1;
248
305
  }
249
306
 
250
307
  .cc-messagecomposer__emojikeyboard {