@bcc-code/vue-bcc-chat-ui 1.4.2 → 1.6.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/dist/chat/connection.d.ts +7 -8
- package/dist/chat/data.d.ts +2 -2
- package/dist/chat/index.d.ts +12 -5
- package/dist/chat/login.d.ts +9 -0
- package/dist/chat/mobileView.d.ts +1 -0
- package/dist/chat/token.d.ts +1 -3
- package/dist/chat/uiKit.d.ts +2 -0
- package/dist/offline/cometChatAPIInterceptor.d.ts +2 -0
- package/dist/offline/cometChatWSInterceptor.d.ts +2 -0
- package/dist/offline/index.d.ts +1 -0
- package/dist/offline/offlineStoreLocalStorage.d.ts +13 -0
- package/dist/offline/types.d.ts +41 -0
- package/dist/vue-bcc-chat-ui.js +13443 -13196
- package/package.json +5 -4
- package/src/components/BccChatMessageList.vue +105 -85
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.
|
|
5
|
+
"version": "1.6.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"files": [
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
"vue": "^3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/
|
|
25
|
+
"@types/lodash-es": "^4.17.12",
|
|
26
|
+
"@types/node": "^20.11.25",
|
|
26
27
|
"@vitejs/plugin-vue": "^4.6.2",
|
|
27
28
|
"path": "^0.12.7",
|
|
28
29
|
"sass": "^1.71.1",
|
|
29
|
-
"typescript": "^5.
|
|
30
|
-
"vite": "^5.1.
|
|
30
|
+
"typescript": "^5.4.2",
|
|
31
|
+
"vite": "^5.1.5",
|
|
31
32
|
"vite-plugin-dts": "^3.7.3",
|
|
32
33
|
"vue": "^3.4.21"
|
|
33
34
|
},
|
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { onBeforeMount, onMounted, onUnmounted, ref, nextTick, watch, Ref } from "vue";
|
|
3
|
-
import chat from
|
|
4
|
-
import {
|
|
3
|
+
import chat from "../chat";
|
|
4
|
+
import { connect, disconnect } from "../chat/connection";
|
|
5
|
+
import { loggedIn } from "../chat/login";
|
|
6
|
+
|
|
7
|
+
import {
|
|
5
8
|
CometChatMessages,
|
|
6
9
|
CometChatMessageTemplate,
|
|
7
10
|
CometChatUIKit,
|
|
8
11
|
ImageBubbleStyle,
|
|
9
12
|
MessageBubbleAlignment,
|
|
10
13
|
} from "@cometchat/chat-uikit-vue";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
import {
|
|
15
|
+
MessageListConfiguration,
|
|
16
|
+
MessageComposerConfiguration,
|
|
17
|
+
} from "@cometchat/uikit-shared";
|
|
18
|
+
import { CometChatTheme } from "@cometchat/uikit-resources";
|
|
19
|
+
import { BaseMessage, Group, User } from "@cometchat/chat-sdk-javascript";
|
|
14
20
|
import { watchAndApplyStyle } from "../chat/mobileView";
|
|
15
21
|
|
|
16
|
-
//import { ThreadedMessagesStyle } from '@cometchat/uikit-shared';
|
|
17
|
-
|
|
18
22
|
const props = defineProps({
|
|
19
|
-
chatUid:
|
|
20
|
-
})
|
|
23
|
+
chatUid: { type: String, required: true },
|
|
24
|
+
});
|
|
21
25
|
|
|
22
|
-
const componentId = ref(
|
|
23
|
-
|
|
26
|
+
const componentId = ref(
|
|
27
|
+
`component-${Math.random().toString(36).substring(2, 11)}`
|
|
28
|
+
);
|
|
29
|
+
const chatGroup = ref<Group | null>(null);
|
|
24
30
|
|
|
25
|
-
watch(chatGroup, (exists:
|
|
31
|
+
watch(chatGroup, (exists: null) => {
|
|
26
32
|
if (!exists) return;
|
|
33
|
+
|
|
27
34
|
nextTick(() => {
|
|
28
35
|
watchAndApplyStyle(
|
|
29
36
|
".bcc-chat-message-list",
|
|
@@ -34,58 +41,54 @@ watch(chatGroup, (exists: any) => {
|
|
|
34
41
|
});
|
|
35
42
|
})
|
|
36
43
|
|
|
37
|
-
onBeforeMount(async() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
await loadData();
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error('Failed to connect when mounting chat component', error);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
watch(chat.connection.connected, async () => {
|
|
47
|
-
if (chat.connection.connected.value) {
|
|
48
|
-
await loadData();
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
watch(() => props.chatUid, async () => {
|
|
53
|
-
if (chat.connection.connected.value) {
|
|
54
|
-
await loadData();
|
|
55
|
-
}
|
|
44
|
+
onBeforeMount(async () => {
|
|
45
|
+
await connect(componentId.value);
|
|
46
|
+
await loadData();
|
|
56
47
|
});
|
|
57
48
|
|
|
58
49
|
onUnmounted(async () => {
|
|
59
|
-
await disconnect();
|
|
50
|
+
await disconnect(componentId.value);
|
|
60
51
|
});
|
|
61
52
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const connect = async() => {
|
|
69
|
-
await chat.connection.connect(componentId.value);
|
|
70
|
-
};
|
|
53
|
+
watch(
|
|
54
|
+
[loggedIn, chat.connection.connected, chat.initialized, () => props.chatUid],
|
|
55
|
+
() => {
|
|
56
|
+
loadData();
|
|
57
|
+
}
|
|
58
|
+
);
|
|
71
59
|
|
|
72
60
|
// Loads data if chat is connected
|
|
73
|
-
const loadData = async () => {
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
const loadData = async () => {
|
|
62
|
+
if (
|
|
63
|
+
loggedIn.value &&
|
|
64
|
+
chat.initialized.value &&
|
|
65
|
+
chat.connection.connected.value
|
|
66
|
+
) {
|
|
67
|
+
initTemplates();
|
|
68
|
+
if (props.chatUid) {
|
|
69
|
+
// Retreive group
|
|
76
70
|
chatGroup.value = await chat.data.getGroup(props.chatUid);
|
|
77
|
-
|
|
71
|
+
|
|
72
|
+
// Clear group chat count - assume user is viewing chat
|
|
73
|
+
if (chatGroup.value) {
|
|
74
|
+
await chat.data.clearGroupChatCount(props.chatUid);
|
|
75
|
+
}
|
|
78
76
|
} else {
|
|
79
|
-
chatGroup.value =
|
|
77
|
+
chatGroup.value = null;
|
|
80
78
|
}
|
|
79
|
+
} else {
|
|
80
|
+
if (!loggedIn.value) {
|
|
81
|
+
chatGroup.value = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
81
84
|
};
|
|
82
85
|
|
|
83
86
|
const messageComposerConfiguration = new MessageComposerConfiguration({
|
|
84
87
|
hideLiveReaction: true,
|
|
85
|
-
hideVoiceRecording: true
|
|
88
|
+
hideVoiceRecording: true,
|
|
86
89
|
});
|
|
87
|
-
const messageListConfiguration:Ref<any> = ref(null);
|
|
88
|
-
|
|
90
|
+
const messageListConfiguration: Ref<any> = ref(null);
|
|
91
|
+
|
|
89
92
|
// Templates cannot be initialized before CometChat is initiazlied
|
|
90
93
|
// CometChatUIKit.getDataSource().getAllMessageTemplates() will return null before cometchat is initialized
|
|
91
94
|
// So we postpone overriding the templates until cometchat is connected
|
|
@@ -100,16 +103,25 @@ const initTemplates = () => {
|
|
|
100
103
|
|
|
101
104
|
// Override message list configuration
|
|
102
105
|
function getMessageListConfiguration(): MessageListConfiguration {
|
|
103
|
-
let templates = CometChatUIKit.getDataSource()
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
let templates = CometChatUIKit.getDataSource()
|
|
107
|
+
.getAllMessageTemplates()
|
|
108
|
+
.map((template: CometChatMessageTemplate) => {
|
|
109
|
+
// Override options
|
|
110
|
+
template.options = (
|
|
111
|
+
loggedInUser: User,
|
|
112
|
+
message: BaseMessage,
|
|
113
|
+
theme: CometChatTheme,
|
|
114
|
+
group: Group | undefined
|
|
115
|
+
) => {
|
|
116
|
+
return getOptionsView(loggedInUser, message, theme, group);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// Override image styling
|
|
120
|
+
if (template.category === "message" && template.type === "image") {
|
|
121
|
+
template.contentView = getImageMessageContentView;
|
|
122
|
+
}
|
|
123
|
+
return template;
|
|
124
|
+
});
|
|
113
125
|
|
|
114
126
|
function getImageMessageContentView(
|
|
115
127
|
message: CometChat.BaseMessage,
|
|
@@ -132,40 +144,48 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
132
144
|
}),
|
|
133
145
|
},
|
|
134
146
|
};
|
|
135
|
-
}
|
|
147
|
+
}
|
|
136
148
|
|
|
137
|
-
const getOptionsView = (
|
|
138
|
-
|
|
139
|
-
|
|
149
|
+
const getOptionsView = (
|
|
150
|
+
loggedInUser: User,
|
|
151
|
+
message: BaseMessage,
|
|
152
|
+
theme: any,
|
|
153
|
+
group: Group | undefined
|
|
154
|
+
) => {
|
|
155
|
+
const optionsData = CometChatUIKit.getDataSource().getMessageOptions(
|
|
156
|
+
loggedInUser,
|
|
157
|
+
message,
|
|
158
|
+
theme,
|
|
159
|
+
group
|
|
160
|
+
);
|
|
161
|
+
const customOptionsView = optionsData.filter(
|
|
162
|
+
(ele) => ele.id !== "sendMessagePrivately"
|
|
163
|
+
);
|
|
140
164
|
return customOptionsView;
|
|
141
|
-
}
|
|
142
|
-
|
|
165
|
+
};
|
|
143
166
|
|
|
144
167
|
return new MessageListConfiguration({
|
|
145
168
|
scrollToBottomOnNewMessages: true,
|
|
146
|
-
templates: templates
|
|
169
|
+
templates: templates,
|
|
147
170
|
});
|
|
148
171
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
172
|
</script>
|
|
152
173
|
|
|
153
174
|
<template>
|
|
154
175
|
<div v-if="chatGroup" class="bcc-chat-message-list">
|
|
155
|
-
<CometChatMessages
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
176
|
+
<CometChatMessages
|
|
177
|
+
:hideMessageHeader="true"
|
|
178
|
+
:disableSoundForMessages="true"
|
|
179
|
+
:messageComposerConfiguration="messageComposerConfiguration"
|
|
180
|
+
:messageListConfiguration="messageListConfiguration"
|
|
181
|
+
:hideMessageComposer="false"
|
|
182
|
+
:hideDetails="true"
|
|
183
|
+
:group="chatGroup"
|
|
184
|
+
/>
|
|
164
185
|
</div>
|
|
165
186
|
</template>
|
|
166
187
|
|
|
167
|
-
<style lang="scss"
|
|
168
|
-
|
|
188
|
+
<style lang="scss">
|
|
169
189
|
.bcc-chat-message-list {
|
|
170
190
|
height: 100%;
|
|
171
191
|
/* 1. Wrapper for Messages component */
|
|
@@ -180,13 +200,14 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
180
200
|
}
|
|
181
201
|
}
|
|
182
202
|
|
|
183
|
-
.cc-messagecomposer__emojikeyboard {
|
|
184
|
-
|
|
203
|
+
.cc-messagecomposer__emojikeyboard {
|
|
204
|
+
display: none;
|
|
185
205
|
}
|
|
186
206
|
|
|
187
207
|
// Hide emoji keyboard
|
|
188
|
-
.cc-messagecomposer__emojikeyboard {
|
|
189
|
-
|
|
208
|
+
.cc-messagecomposer__emojikeyboard {
|
|
209
|
+
display: none;
|
|
210
|
+
}
|
|
190
211
|
|
|
191
212
|
.cc-threadedmessages-wrapper__bubbleview::-webkit-scrollbar,
|
|
192
213
|
.cc__message-list::-webkit-scrollbar {
|
|
@@ -199,5 +220,4 @@ function getMessageListConfiguration(): MessageListConfiguration {
|
|
|
199
220
|
background: rgb(232, 229, 229);
|
|
200
221
|
border-radius: 8px;
|
|
201
222
|
}
|
|
202
|
-
|
|
203
|
-
</style>
|
|
223
|
+
</style>
|