@bcc-code/vue-bcc-chat-ui 1.2.7 → 1.2.9

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.7",
5
+ "version": "1.2.9",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -9,8 +9,9 @@ import {
9
9
  MessageBubbleAlignment,
10
10
  } from "@cometchat/chat-uikit-vue";
11
11
  import { MessageListConfiguration, MessageComposerConfiguration } from "@cometchat/uikit-shared";
12
+ import { CometChatTheme } from '@cometchat/uikit-resources'
12
13
  import { Group } from '@cometchat/chat-sdk-javascript';
13
- import { watch, Ref } from 'vue';
14
+ import { watch } from 'vue';
14
15
  //import { ThreadedMessagesStyle } from '@cometchat/uikit-shared';
15
16
 
16
17
  const props = defineProps({
@@ -21,7 +22,7 @@ const componentId = ref(`component-${Math.random().toString(36).substring(2, 11)
21
22
  const chatGroup = ref<Group>();
22
23
 
23
24
  onBeforeMount(async() => {
24
- await connnect();
25
+ await connect();
25
26
  await loadData();
26
27
  });
27
28
 
@@ -48,14 +49,13 @@ const disconnect = async () => {
48
49
  };
49
50
 
50
51
  // Connect to chat server
51
- const connnect = async() => {
52
+ const connect = async() => {
52
53
  await chat.connection.connect(componentId.value);
53
54
  };
54
55
 
55
56
  // Loads data if chat is connected
56
57
  const loadData = async () => {
57
58
  if (chat.connection.connected.value && props.chatUid) {
58
- initTemplates();
59
59
  chatGroup.value = await chat.data.getGroup(props.chatUid);
60
60
  await chat.data.clearGroupChatCount(props.chatUid);
61
61
  } else {
@@ -63,57 +63,65 @@ const loadData = async () => {
63
63
  }
64
64
  };
65
65
 
66
- const messageListConfiguration:Ref<any> = ref(null);
67
- const messageComposerConfiguration:Ref<any> = ref(new MessageComposerConfiguration({
66
+ const messageComposerConfiguration = new MessageComposerConfiguration({
68
67
  hideLiveReaction: true,
69
68
  hideVoiceRecording: true
70
- }));
69
+ });
71
70
 
72
- let templatesInitialized = false;
73
- const initTemplates = () => {
74
- if (templatesInitialized) {
75
- return;
76
- }
77
- templatesInitialized = true;
78
- let definedTemplates = CometChatUIKit.getDataSource().getAllMessageTemplates();
79
- definedTemplates.map((template: CometChatMessageTemplate) => {
71
+ const messageListConfiguration = getMessageListConfiguration()
72
+
73
+ function getMessageListConfiguration(): MessageListConfiguration {
74
+ let templates = CometChatUIKit.getDataSource().getAllMessageTemplates().map((template: CometChatMessageTemplate) => {
80
75
  if (template.category === "message" && template.type === "image") {
81
- template.contentView = (
82
- message: CometChat.BaseMessage,
83
- _alignment: MessageBubbleAlignment
84
- ) => getImageMessageContentView(message, _alignment);
76
+ template.contentView = getImageMessageContentView
85
77
  }
86
78
  return template;
87
79
  });
88
80
 
89
- const getImageMessageContentView = (
90
- message: CometChat.BaseMessage,
91
- _alignment: MessageBubbleAlignment
92
- ) => {
93
- return {
94
- componentName: "CometChatImageBubble",
95
- props: {
96
- src: message.getData().url,
97
- imageStyle: new ImageBubbleStyle({
98
- // you can adjust image styles here
99
- width: "100%",
100
- height: "100%",
101
- }),
102
- },
103
- };
81
+ function getImageMessageContentView(
82
+ message: CometChat.BaseMessage,
83
+ _alignment: MessageBubbleAlignment
84
+ ) {
85
+ if (message.getDeletedAt()) {
86
+ return CometChatUIKit.getDataSource().getDeleteMessageBubble(
87
+ message,
88
+ new CometChatTheme({})
89
+ );
90
+ }
91
+ return {
92
+ componentName: "CometChatImageBubble",
93
+ props: {
94
+ src: message.getData().url,
95
+ imageStyle: new ImageBubbleStyle({
96
+ // you can adjust image styles here
97
+ width: "100%",
98
+ height: "100%",
99
+ }),
100
+ },
104
101
  };
102
+ };
105
103
 
106
- messageListConfiguration.value = new MessageListConfiguration({
107
- scrollToBottomOnNewMessages: true,
108
- templates: definedTemplates,
109
- });
104
+ return new MessageListConfiguration({
105
+ scrollToBottomOnNewMessages: true,
106
+ templates: templates
107
+ });
110
108
  }
111
109
 
110
+
112
111
  </script>
113
112
 
114
113
  <template>
115
114
  <div v-if="chatGroup" class="bcc-chat-message-list">
116
- <CometChatMessages v-if="chatGroup" :hideMessageHeader="true" :disableSoundForMessages="true" :messageComposerConfiguration="messageComposerConfiguration" :messageListConfiguration="messageListConfiguration" :hideMessageComposer="false" :hideDetails="true" :group="chatGroup"></CometChatMessages>
115
+ <CometChatMessages
116
+ v-if="chatGroup"
117
+ :hideMessageHeader="true"
118
+ :disableSoundForMessages="true"
119
+ :messageComposerConfiguration="messageComposerConfiguration"
120
+ :messageListConfiguration="messageListConfiguration"
121
+ :hideMessageComposer="false"
122
+ :hideDetails="true"
123
+ :group="chatGroup"
124
+ />
117
125
  </div>
118
126
  </template>
119
127