@bcc-code/vue-bcc-chat-ui 1.2.12 → 1.3.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": "1.2.12",
5
+ "version": "1.3.0",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -36,6 +36,7 @@
36
36
  "@cometchat/chat-uikit-vue": "^4.2.1",
37
37
  "@cometchat/uikit-resources": "^4.2.2",
38
38
  "@cometchat/uikit-shared": "^4.2.2",
39
+ "jwt-decode": "^4.0.0",
39
40
  "lodash-es": "^4.17.21"
40
41
  },
41
42
  "scripts": {
@@ -23,8 +23,12 @@ const componentId = ref(`component-${Math.random().toString(36).substring(2, 11)
23
23
  const chatGroup = ref<Group>();
24
24
 
25
25
  onBeforeMount(async() => {
26
- await connect();
27
- await loadData();
26
+ try {
27
+ await connect();
28
+ await loadData();
29
+ } catch (error) {
30
+ console.error('Failed to connect when mounting chat component', error);
31
+ }
28
32
  });
29
33
 
30
34
  watch(chat.connection.connected, async () => {
@@ -34,7 +38,6 @@ watch(chat.connection.connected, async () => {
34
38
  });
35
39
 
36
40
  watch(() => props.chatUid, async () => {
37
- console.log(props.chatUid + ' Changed');
38
41
  if (chat.connection.connected.value) {
39
42
  await loadData();
40
43
  }
@@ -57,6 +60,7 @@ const connect = async() => {
57
60
  // Loads data if chat is connected
58
61
  const loadData = async () => {
59
62
  if (chat.connection.connected.value && props.chatUid) {
63
+ initTemplates();
60
64
  chatGroup.value = await chat.data.getGroup(props.chatUid);
61
65
  await chat.data.clearGroupChatCount(props.chatUid);
62
66
  } else {
@@ -68,9 +72,21 @@ const messageComposerConfiguration = new MessageComposerConfiguration({
68
72
  hideLiveReaction: true,
69
73
  hideVoiceRecording: true
70
74
  });
75
+ const messageListConfiguration:Ref<any> = ref(null);
76
+
77
+ // Templates cannot be initialized before CometChat is initiazlied
78
+ // CometChatUIKit.getDataSource().getAllMessageTemplates() will return null before cometchat is initialized
79
+ // So we postpone overriding the templates until cometchat is connected
80
+ let templatesInitialized = false;
81
+ const initTemplates = () => {
82
+ if (templatesInitialized) {
83
+ return;
84
+ }
85
+ templatesInitialized = true;
86
+ messageListConfiguration.value = getMessageListConfiguration();
87
+ };
71
88
 
72
- const messageListConfiguration = getMessageListConfiguration()
73
-
89
+ // Override message list configuration
74
90
  function getMessageListConfiguration(): MessageListConfiguration {
75
91
  let templates = CometChatUIKit.getDataSource().getAllMessageTemplates().map((template: CometChatMessageTemplate) => {
76
92
  // Override options