@phonghq/go-chat 1.0.52 → 1.0.54
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/App.vue.js +0 -2
- package/dist/chat/page/home/ChatList.vue.d.ts +4 -0
- package/dist/chat/page/home/ChatList.vue.js +4 -4
- package/dist/chat/page/home/ChatMessageItem.vue.js +17 -13
- package/dist/chat/page/home/Home.vue.js +13 -13
- package/dist/chat/page/home/HomeHeader.vue.js +4 -0
- package/dist/chat/page/home/InputChat.vue.js +3 -2
- package/dist/chat/page/home/PhoneNumpad.vue.js +19 -20
- package/dist/composable/useListConversations.d.ts +2 -0
- package/dist/composable/useListConversations.js +35 -22
- package/dist/constant/mqtt.js +4 -3
- package/dist/go-chat.es.js +33163 -29316
- package/dist/go-chat.umd.js +32 -16
- package/dist/plugins/mqtt.d.ts +3 -5
- package/dist/plugins/mqtt.js +86 -50
- package/dist/style.css +1 -1
- package/dist/types/conversation.d.ts +1 -0
- package/dist/utils/chat/page-error.d.ts +1 -1
- package/dist/utils/chat/store/conversation.js +6 -8
- package/dist/views/home/phone-numpad/ConvercationList.vue.d.ts +1 -1
- package/dist/views/home/phone-numpad/ConvercationList.vue.js +1 -1
- package/dist/views/home/phone-numpad/PhoneNumpad.vue.js +141 -51
- package/package.json +2 -2
package/dist/chat/App.vue.js
CHANGED
|
@@ -819,7 +819,6 @@ else {
|
|
|
819
819
|
hideNumpad: (__VLS_ctx.isLib),
|
|
820
820
|
responsive: (__VLS_ctx.responsiveRender),
|
|
821
821
|
...{ class: "bg-white shrink-0 border-l layout-border" },
|
|
822
|
-
modelValue: "",
|
|
823
822
|
}));
|
|
824
823
|
const __VLS_119 = __VLS_118({
|
|
825
824
|
...{ 'onCall': {} },
|
|
@@ -827,7 +826,6 @@ else {
|
|
|
827
826
|
hideNumpad: (__VLS_ctx.isLib),
|
|
828
827
|
responsive: (__VLS_ctx.responsiveRender),
|
|
829
828
|
...{ class: "bg-white shrink-0 border-l layout-border" },
|
|
830
|
-
modelValue: "",
|
|
831
829
|
}, ...__VLS_functionalComponentArgsRest(__VLS_118));
|
|
832
830
|
let __VLS_121;
|
|
833
831
|
let __VLS_122;
|
|
@@ -25,6 +25,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
25
25
|
color: string;
|
|
26
26
|
is_unknown: number;
|
|
27
27
|
customer_id?: number | undefined;
|
|
28
|
+
tenant_id?: number | undefined;
|
|
28
29
|
}[], IConversation[] | {
|
|
29
30
|
id: number;
|
|
30
31
|
receiver_id: number;
|
|
@@ -40,6 +41,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
40
41
|
color: string;
|
|
41
42
|
is_unknown: number;
|
|
42
43
|
customer_id?: number | undefined;
|
|
44
|
+
tenant_id?: number | undefined;
|
|
43
45
|
}[]>;
|
|
44
46
|
listConversationsUnknown: import("vue").Ref<{
|
|
45
47
|
id: number;
|
|
@@ -56,6 +58,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
56
58
|
color: string;
|
|
57
59
|
is_unknown: number;
|
|
58
60
|
customer_id?: number | undefined;
|
|
61
|
+
tenant_id?: number | undefined;
|
|
59
62
|
}[], IConversation[] | {
|
|
60
63
|
id: number;
|
|
61
64
|
receiver_id: number;
|
|
@@ -71,6 +74,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
71
74
|
color: string;
|
|
72
75
|
is_unknown: number;
|
|
73
76
|
customer_id?: number | undefined;
|
|
77
|
+
tenant_id?: number | undefined;
|
|
74
78
|
}[]>;
|
|
75
79
|
getCurrentConversation: () => IConversation | undefined;
|
|
76
80
|
initData: (option?: {
|
|
@@ -193,10 +193,10 @@ const initData = async (option) => {
|
|
|
193
193
|
selectUser(conversation);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
handleTabChange(
|
|
197
|
-
handleTabChange(
|
|
198
|
-
hideCheckHasReceiveId,
|
|
199
|
-
hideLoading:
|
|
196
|
+
handleTabChange(activeTabs.value, { hideCheckHasReceiveId: hideCheckHasReceiveId });
|
|
197
|
+
handleTabChange(activeTabs.value == 1 ? 0 : 1, {
|
|
198
|
+
hideCheckHasReceiveId: true,
|
|
199
|
+
hideLoading: true
|
|
200
200
|
});
|
|
201
201
|
};
|
|
202
202
|
const __VLS_exposed = {
|
|
@@ -138,19 +138,21 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending || __VLS_ctx.isMyM
|
|
|
138
138
|
}
|
|
139
139
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({});
|
|
140
140
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
141
|
-
...{ class: "px-3 py-2 rounded-2xl max-w-
|
|
141
|
+
...{ class: "px-3 py-2 rounded-2xl max-w-[280px] text-left w-max" },
|
|
142
142
|
...{ class: ({
|
|
143
|
-
'rounded-tl-
|
|
144
|
-
'rounded-bl-
|
|
145
|
-
'rounded-tr-
|
|
146
|
-
'rounded-br-
|
|
143
|
+
'rounded-tl-[6px]': !__VLS_ctx.isChatStart && !__VLS_ctx.isMyMessage,
|
|
144
|
+
'rounded-bl-[6px]': !__VLS_ctx.isChatFinished && !__VLS_ctx.isMyMessage,
|
|
145
|
+
'rounded-tr-[6px]': !__VLS_ctx.isChatStart && __VLS_ctx.isMyMessage,
|
|
146
|
+
'rounded-br-[6px]': !__VLS_ctx.isChatFinished && __VLS_ctx.isMyMessage,
|
|
147
147
|
'!text-white !bg-chat-success': (__VLS_ctx.message.message_uuid && !__VLS_ctx.message.is_call) || __VLS_ctx.message.is_sms,
|
|
148
148
|
'bg-chat-primary text-white': __VLS_ctx.isMyMessage && !__VLS_ctx.message.is_call,
|
|
149
|
-
'bg-[#E4E4E4D4] text-chat-haze-600
|
|
149
|
+
'bg-[#E4E4E4D4] text-chat-haze-600': !__VLS_ctx.isMyMessage || __VLS_ctx.message.is_call,
|
|
150
|
+
' ml-auto ': __VLS_ctx.isMyMessage,
|
|
151
|
+
' mr-auto ': !__VLS_ctx.isMyMessage
|
|
150
152
|
}) },
|
|
151
153
|
});
|
|
152
154
|
// @ts-ignore
|
|
153
|
-
[isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, message, message, message, message, message, isChatStart, isChatStart, isChatFinished, isChatFinished,];
|
|
155
|
+
[isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, message, message, message, message, message, isChatStart, isChatStart, isChatFinished, isChatFinished,];
|
|
154
156
|
if (__VLS_ctx.message.is_call == 1) {
|
|
155
157
|
// @ts-ignore
|
|
156
158
|
[message,];
|
|
@@ -286,19 +288,21 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending || __VLS_ctx.isMyM
|
|
|
286
288
|
/** @type {__VLS_StyleScopedClasses['px-3']} */ ;
|
|
287
289
|
/** @type {__VLS_StyleScopedClasses['py-2']} */ ;
|
|
288
290
|
/** @type {__VLS_StyleScopedClasses['rounded-2xl']} */ ;
|
|
289
|
-
/** @type {__VLS_StyleScopedClasses['max-w-
|
|
291
|
+
/** @type {__VLS_StyleScopedClasses['max-w-[280px]']} */ ;
|
|
290
292
|
/** @type {__VLS_StyleScopedClasses['text-left']} */ ;
|
|
291
|
-
/** @type {__VLS_StyleScopedClasses['
|
|
292
|
-
/** @type {__VLS_StyleScopedClasses['rounded-
|
|
293
|
-
/** @type {__VLS_StyleScopedClasses['rounded-
|
|
294
|
-
/** @type {__VLS_StyleScopedClasses['rounded-
|
|
293
|
+
/** @type {__VLS_StyleScopedClasses['w-max']} */ ;
|
|
294
|
+
/** @type {__VLS_StyleScopedClasses['rounded-tl-[6px]']} */ ;
|
|
295
|
+
/** @type {__VLS_StyleScopedClasses['rounded-bl-[6px]']} */ ;
|
|
296
|
+
/** @type {__VLS_StyleScopedClasses['rounded-tr-[6px]']} */ ;
|
|
297
|
+
/** @type {__VLS_StyleScopedClasses['rounded-br-[6px]']} */ ;
|
|
295
298
|
/** @type {__VLS_StyleScopedClasses['!text-white']} */ ;
|
|
296
299
|
/** @type {__VLS_StyleScopedClasses['!bg-chat-success']} */ ;
|
|
297
300
|
/** @type {__VLS_StyleScopedClasses['bg-chat-primary']} */ ;
|
|
298
301
|
/** @type {__VLS_StyleScopedClasses['text-white']} */ ;
|
|
299
302
|
/** @type {__VLS_StyleScopedClasses['bg-[#E4E4E4D4]']} */ ;
|
|
300
303
|
/** @type {__VLS_StyleScopedClasses['text-chat-haze-600']} */ ;
|
|
301
|
-
/** @type {__VLS_StyleScopedClasses['
|
|
304
|
+
/** @type {__VLS_StyleScopedClasses['ml-auto']} */ ;
|
|
305
|
+
/** @type {__VLS_StyleScopedClasses['mr-auto']} */ ;
|
|
302
306
|
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
303
307
|
/** @type {__VLS_StyleScopedClasses['flex-col']} */ ;
|
|
304
308
|
/** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
|
|
@@ -6,7 +6,7 @@ import { getDetailReceiver, getMessage, sendMessage, upLoadImage } from '../../.
|
|
|
6
6
|
import { computed, nextTick, onMounted, onUnmounted, ref, shallowRef } from 'vue';
|
|
7
7
|
import ChatMessage from '../../../chat/page/home/ChatMessage.vue';
|
|
8
8
|
import { addHandleMqttMessage, connectMqtt, publishMessage, removeHandleMqttMessage, subscribeToTopic, unsubscribeFromTopic } from '../../../plugins/mqtt';
|
|
9
|
-
import {
|
|
9
|
+
import { TOPIC_PLIVO_SMS } from '../../../constant/mqtt';
|
|
10
10
|
import { MessageState } from '../../../constant/message';
|
|
11
11
|
import { publicTopicConversationUpdate } from '../../../utils/chat/store/conversation';
|
|
12
12
|
import { getCache, removeOldestCache, setCache } from '../../../utils/chat/cache';
|
|
@@ -31,11 +31,11 @@ onUnmounted(() => {
|
|
|
31
31
|
const handleConnectMqtt = async () => {
|
|
32
32
|
try {
|
|
33
33
|
await connectMqtt();
|
|
34
|
-
topic = TOPIC_DETAIL_CHAT + infoUser.value?.conversation_id
|
|
34
|
+
// topic = TOPIC_DETAIL_CHAT + infoUser.value?.conversation_id
|
|
35
35
|
topic_plivo_chat = TOPIC_PLIVO_SMS + infoUser.value?.conversation_id;
|
|
36
|
-
subscribeToTopic(topic)
|
|
36
|
+
// subscribeToTopic(topic)
|
|
37
37
|
subscribeToTopic(topic_plivo_chat);
|
|
38
|
-
addHandleMqttMessage('chat-home', topic, mqttMessageHandler)
|
|
38
|
+
// addHandleMqttMessage('chat-home', topic, mqttMessageHandler)
|
|
39
39
|
addHandleMqttMessage('chat-home-1', topic_plivo_chat, mqttMessageHandler);
|
|
40
40
|
}
|
|
41
41
|
catch (error) {
|
|
@@ -43,9 +43,9 @@ const handleConnectMqtt = async () => {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
const handleDisconnectMqtt = async () => {
|
|
46
|
-
unsubscribeFromTopic(topic)
|
|
47
|
-
unsubscribeFromTopic(topic_plivo_chat);
|
|
48
|
-
removeHandleMqttMessage('chat-home')
|
|
46
|
+
// unsubscribeFromTopic(topic)
|
|
47
|
+
await unsubscribeFromTopic(topic_plivo_chat);
|
|
48
|
+
// removeHandleMqttMessage('chat-home')
|
|
49
49
|
removeHandleMqttMessage('chat-home-1');
|
|
50
50
|
};
|
|
51
51
|
const mqttMessageHandler = (topic, message) => {
|
|
@@ -112,7 +112,7 @@ const handleGetDetailReceiver = async (data) => {
|
|
|
112
112
|
const res = (await getDetailReceiver(props.receiverId)) ?? null;
|
|
113
113
|
if (id == props.receiverId) {
|
|
114
114
|
infoUser.value = res;
|
|
115
|
-
handleDisconnectMqtt();
|
|
115
|
+
await handleDisconnectMqtt();
|
|
116
116
|
await handleConnectMqtt();
|
|
117
117
|
}
|
|
118
118
|
};
|
|
@@ -146,10 +146,10 @@ const handleSendMessage = async (data) => {
|
|
|
146
146
|
// listMessage.value.push({ ...data, state: MessageState.Sending })
|
|
147
147
|
listMessage.value.unshift({ ...data, state: MessageState.Sending });
|
|
148
148
|
await nextTick();
|
|
149
|
-
publishMessage(topic, {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
})
|
|
149
|
+
// publishMessage(topic, {
|
|
150
|
+
// ...data,
|
|
151
|
+
// state: MessageState.Sending
|
|
152
|
+
// })
|
|
153
153
|
let file_upload = [];
|
|
154
154
|
if (data?.attachments?.length) {
|
|
155
155
|
updateMessageItem(data.id, { state: MessageState.Uploading });
|
|
@@ -164,7 +164,7 @@ const handleSendMessage = async (data) => {
|
|
|
164
164
|
formData.append('url', file_upload[0]?.url ?? '');
|
|
165
165
|
}
|
|
166
166
|
await sendMessage(formData);
|
|
167
|
-
publishMessage(
|
|
167
|
+
publishMessage(topic_plivo_chat, {
|
|
168
168
|
...data,
|
|
169
169
|
state: MessageState.Sent,
|
|
170
170
|
attachments: file_upload
|
|
@@ -53,7 +53,10 @@ let __VLS_components;
|
|
|
53
53
|
let __VLS_directives;
|
|
54
54
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
55
55
|
...{ class: "px-8 py-4 h-[96px] layout-shadow border-b border-chat-gray-5 z-10" },
|
|
56
|
+
...{ class: ({ '!px-4': __VLS_ctx.responsive == 'mobile' }) },
|
|
56
57
|
});
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
[responsive,];
|
|
57
60
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
58
61
|
...{ class: "flex items-center gap-2 h-full" },
|
|
59
62
|
});
|
|
@@ -193,6 +196,7 @@ if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() &
|
|
|
193
196
|
/** @type {__VLS_StyleScopedClasses['border-b']} */ ;
|
|
194
197
|
/** @type {__VLS_StyleScopedClasses['border-chat-gray-5']} */ ;
|
|
195
198
|
/** @type {__VLS_StyleScopedClasses['z-10']} */ ;
|
|
199
|
+
/** @type {__VLS_StyleScopedClasses['!px-4']} */ ;
|
|
196
200
|
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
197
201
|
/** @type {__VLS_StyleScopedClasses['items-center']} */ ;
|
|
198
202
|
/** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
|
|
@@ -46,7 +46,7 @@ const handleSendMessage = async (type) => {
|
|
|
46
46
|
keyword.value = '';
|
|
47
47
|
// chatInputRef.value.style.height = 'auto'
|
|
48
48
|
chatId++;
|
|
49
|
-
const id = props.data?.id.toString() + '-' + chatId;
|
|
49
|
+
const id = props.data?.id.toString() + '-' + chatId + '-' + Date.now();
|
|
50
50
|
const data = {
|
|
51
51
|
conversation_id: props.data?.conversation_id,
|
|
52
52
|
created_at: dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']),
|
|
@@ -149,7 +149,7 @@ __VLS_asFunctionalElement(__VLS_elements.textarea)({
|
|
|
149
149
|
// @ts-ignore
|
|
150
150
|
[setInputHeight,];
|
|
151
151
|
} },
|
|
152
|
-
...{ class: "text-[14px] sm:text-base w-full min-h-11 overflow-hidden chat-input !rounded-xl px-4 py-2 border border-chat-haze-200" },
|
|
152
|
+
...{ class: "text-[14px] sm:text-base w-full min-h-11 overflow-hidden chat-input !rounded-xl px-4 py-2 border border-chat-haze-200 leading-[24px]" },
|
|
153
153
|
ref: "chatInputRef",
|
|
154
154
|
rows: "1",
|
|
155
155
|
placeholder: "Send Message",
|
|
@@ -310,6 +310,7 @@ const __VLS_19 = __VLS_18({
|
|
|
310
310
|
/** @type {__VLS_StyleScopedClasses['py-2']} */ ;
|
|
311
311
|
/** @type {__VLS_StyleScopedClasses['border']} */ ;
|
|
312
312
|
/** @type {__VLS_StyleScopedClasses['border-chat-haze-200']} */ ;
|
|
313
|
+
/** @type {__VLS_StyleScopedClasses['leading-[24px]']} */ ;
|
|
313
314
|
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
314
315
|
/** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
|
|
315
316
|
/** @type {__VLS_StyleScopedClasses['-translate-y-2']} */ ;
|
|
@@ -50,36 +50,35 @@ if (__VLS_ctx.responsive == 'window') {
|
|
|
50
50
|
let __VLS_4;
|
|
51
51
|
const __VLS_5 = ({ call: {} },
|
|
52
52
|
{ onCall: (__VLS_ctx.handleCall) });
|
|
53
|
+
var __VLS_6 = {};
|
|
53
54
|
// @ts-ignore
|
|
54
55
|
[responsive, hideNumpad, handleCall,];
|
|
55
56
|
var __VLS_2;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
[responsive,];
|
|
58
|
+
else {
|
|
60
59
|
/** @type {[typeof DrawerBaseCustom, typeof DrawerBaseCustom, ]} */ ;
|
|
61
60
|
// @ts-ignore
|
|
62
|
-
const
|
|
61
|
+
const __VLS_8 = __VLS_asFunctionalComponent(DrawerBaseCustom, new DrawerBaseCustom({
|
|
63
62
|
ref: "drawerVisibleRef",
|
|
64
63
|
responsive: (__VLS_ctx.responsive),
|
|
65
64
|
}));
|
|
66
|
-
const
|
|
65
|
+
const __VLS_9 = __VLS_8({
|
|
67
66
|
ref: "drawerVisibleRef",
|
|
68
67
|
responsive: (__VLS_ctx.responsive),
|
|
69
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
68
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_8));
|
|
70
69
|
/** @type {typeof __VLS_ctx.drawerVisibleRef} */ ;
|
|
71
|
-
var
|
|
72
|
-
const { default:
|
|
70
|
+
var __VLS_11 = {};
|
|
71
|
+
const { default: __VLS_13 } = __VLS_10.slots;
|
|
73
72
|
// @ts-ignore
|
|
74
73
|
[responsive, drawerVisibleRef,];
|
|
75
74
|
{
|
|
76
|
-
const { content:
|
|
75
|
+
const { content: __VLS_14 } = __VLS_10.slots;
|
|
77
76
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
78
77
|
...{ class: "h-full flex flex-col" },
|
|
79
78
|
});
|
|
80
79
|
/** @type {[typeof PhoneNumpad, ]} */ ;
|
|
81
80
|
// @ts-ignore
|
|
82
|
-
const
|
|
81
|
+
const __VLS_15 = __VLS_asFunctionalComponent(PhoneNumpad, new PhoneNumpad({
|
|
83
82
|
...{ 'onCall': {} },
|
|
84
83
|
...{ 'onBack': {} },
|
|
85
84
|
ref: "phoneNumpadRef",
|
|
@@ -87,33 +86,33 @@ if (__VLS_ctx.responsive != 'window') {
|
|
|
87
86
|
hideNumpad: (__VLS_ctx.hideNumpad),
|
|
88
87
|
responsive: (__VLS_ctx.responsive),
|
|
89
88
|
}));
|
|
90
|
-
const
|
|
89
|
+
const __VLS_16 = __VLS_15({
|
|
91
90
|
...{ 'onCall': {} },
|
|
92
91
|
...{ 'onBack': {} },
|
|
93
92
|
ref: "phoneNumpadRef",
|
|
94
93
|
...{ class: "bg-white grow border-l layout-border w-full" },
|
|
95
94
|
hideNumpad: (__VLS_ctx.hideNumpad),
|
|
96
95
|
responsive: (__VLS_ctx.responsive),
|
|
97
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
98
|
-
let __VLS_17;
|
|
96
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_15));
|
|
99
97
|
let __VLS_18;
|
|
100
|
-
|
|
98
|
+
let __VLS_19;
|
|
99
|
+
const __VLS_20 = ({ call: {} },
|
|
101
100
|
{ onCall: (__VLS_ctx.handleCall) });
|
|
102
|
-
const
|
|
101
|
+
const __VLS_21 = ({ back: {} },
|
|
103
102
|
{ onBack: (...[$event]) => {
|
|
104
|
-
if (
|
|
103
|
+
if (!!(__VLS_ctx.responsive == 'window'))
|
|
105
104
|
return;
|
|
106
105
|
__VLS_ctx.drawerVisibleRef?.close();
|
|
107
106
|
// @ts-ignore
|
|
108
107
|
[responsive, hideNumpad, handleCall, drawerVisibleRef,];
|
|
109
108
|
} });
|
|
110
109
|
/** @type {typeof __VLS_ctx.phoneNumpadRef} */ ;
|
|
111
|
-
var
|
|
110
|
+
var __VLS_22 = {};
|
|
112
111
|
// @ts-ignore
|
|
113
112
|
[phoneNumpadRef,];
|
|
114
|
-
var
|
|
113
|
+
var __VLS_17;
|
|
115
114
|
}
|
|
116
|
-
var
|
|
115
|
+
var __VLS_10;
|
|
117
116
|
}
|
|
118
117
|
/** @type {__VLS_StyleScopedClasses['bg-white']} */ ;
|
|
119
118
|
/** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
|
|
@@ -128,7 +127,7 @@ if (__VLS_ctx.responsive != 'window') {
|
|
|
128
127
|
/** @type {__VLS_StyleScopedClasses['layout-border']} */ ;
|
|
129
128
|
/** @type {__VLS_StyleScopedClasses['w-full']} */ ;
|
|
130
129
|
// @ts-ignore
|
|
131
|
-
var
|
|
130
|
+
var __VLS_12 = __VLS_11, __VLS_23 = __VLS_22;
|
|
132
131
|
const __VLS_export = (await import('vue')).defineComponent({
|
|
133
132
|
setup: () => (__VLS_exposed),
|
|
134
133
|
__typeEmits: {},
|
|
@@ -15,6 +15,7 @@ export declare const useListConversations: (is_unknown: number, is_tenant: boole
|
|
|
15
15
|
color: string;
|
|
16
16
|
is_unknown: number;
|
|
17
17
|
customer_id?: number | undefined;
|
|
18
|
+
tenant_id?: number | undefined;
|
|
18
19
|
}[], IConversation[] | {
|
|
19
20
|
id: number;
|
|
20
21
|
receiver_id: number;
|
|
@@ -30,6 +31,7 @@ export declare const useListConversations: (is_unknown: number, is_tenant: boole
|
|
|
30
31
|
color: string;
|
|
31
32
|
is_unknown: number;
|
|
32
33
|
customer_id?: number | undefined;
|
|
34
|
+
tenant_id?: number | undefined;
|
|
33
35
|
}[]>;
|
|
34
36
|
params: import("vue").Ref<{
|
|
35
37
|
page: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
|
|
2
|
-
import { TOPIC_HOME
|
|
3
|
-
import { addHandleMqttMessage, connectMqtt, removeHandleMqttMessage, subscribeToTopic, unsubscribeFromTopic } from '../plugins/mqtt';
|
|
2
|
+
import { TOPIC_HOME } from '../constant/mqtt';
|
|
3
|
+
import { addHandleMqttMessage, connectMqtt, publishMessage, removeHandleMqttMessage, subscribeToTopic, unsubscribeFromTopic } from '../plugins/mqtt';
|
|
4
4
|
import { dataProfile } from '../utils/chat/store/auth';
|
|
5
5
|
import { useDebounce } from '../utils/debounce';
|
|
6
6
|
import { getConversation } from '../utils/chat/store/conversation';
|
|
@@ -29,8 +29,8 @@ export const useListConversations = (is_unknown, is_tenant) => {
|
|
|
29
29
|
removeHandleMqttMessage('chat-list-' + item + '-' + is_unknown);
|
|
30
30
|
});
|
|
31
31
|
if (dataProfile.value?.user_type == 'tenant') {
|
|
32
|
-
|
|
33
|
-
removeHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown)
|
|
32
|
+
// unsubscribeFromTopic(TOPIC_STATUS_USER + dataProfile.value?.id)
|
|
33
|
+
// removeHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown)
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
const handleConnectMqtt = async () => {
|
|
@@ -38,12 +38,17 @@ export const useListConversations = (is_unknown, is_tenant) => {
|
|
|
38
38
|
if (dataProfile.value) {
|
|
39
39
|
await connectMqtt();
|
|
40
40
|
TOPIC_HOME.forEach((item) => {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
if (is_unknown == 0) {
|
|
42
|
+
subscribeToTopic(item + dataProfile.value?.id);
|
|
43
|
+
}
|
|
43
44
|
addHandleMqttMessage('chat-list-' + item + '-' + is_unknown, item + dataProfile.value?.id, mqttMessageHandler);
|
|
44
45
|
});
|
|
45
|
-
subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id)
|
|
46
|
-
addHandleMqttMessage(
|
|
46
|
+
// subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id)
|
|
47
|
+
// addHandleMqttMessage(
|
|
48
|
+
// 'chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown,
|
|
49
|
+
// TOPIC_STATUS_USER + dataProfile.value?.id,
|
|
50
|
+
// mqttMessageHandler
|
|
51
|
+
// )
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
catch (error) {
|
|
@@ -53,11 +58,14 @@ export const useListConversations = (is_unknown, is_tenant) => {
|
|
|
53
58
|
const mqttMessageHandler = (topic, data) => {
|
|
54
59
|
if ((data.is_unknown ?? 0) == is_unknown || (!is_tenant && is_unknown == 0)) {
|
|
55
60
|
getDataMqtt();
|
|
56
|
-
if (topic ===
|
|
57
|
-
|
|
61
|
+
if (topic ===
|
|
62
|
+
TOPIC_HOME[0] + dataProfile.value?.id
|
|
63
|
+
// ||topic === TOPIC_HOME[3] + dataProfile.value?.id
|
|
64
|
+
) {
|
|
58
65
|
const index = listConversations.value.findIndex((item) => item.id === data.id);
|
|
59
66
|
const hasChatBox = listConversations.value.findIndex((item) => item.id === digibotId);
|
|
60
67
|
if (index != -1) {
|
|
68
|
+
data.username = listConversations.value[index].username ?? '';
|
|
61
69
|
listConversations.value.splice(index, 1);
|
|
62
70
|
}
|
|
63
71
|
if (hasChatBox > -1) {
|
|
@@ -68,20 +76,24 @@ export const useListConversations = (is_unknown, is_tenant) => {
|
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
if (topic === TOPIC_HOME[1] + dataProfile.value?.id) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (topic === TOPIC_HOME[2] + dataProfile.value?.id) {
|
|
77
|
-
listConversations.value.unshift(data?.conversations);
|
|
78
|
-
}
|
|
79
|
-
if (topic === TOPIC_STATUS_USER + dataProfile.value?.id) {
|
|
80
|
-
const index = listConversations.value.findIndex((e) => e.receiver_id == Number(data?.customer_id));
|
|
81
|
-
if (index != -1) {
|
|
82
|
-
listConversations.value[index].status = data.is_online ? 1 : 0;
|
|
79
|
+
if (data.is_unknown == is_unknown) {
|
|
80
|
+
const index = listConversations.value.findIndex((item) => item.id === data.id);
|
|
81
|
+
if (index != -1) {
|
|
82
|
+
listConversations.value[index].unread_count = 0;
|
|
83
|
+
}
|
|
83
84
|
}
|
|
84
85
|
}
|
|
86
|
+
// if (topic === TOPIC_HOME[2] + dataProfile.value?.id) {
|
|
87
|
+
// listConversations.value.unshift(data?.conversations)
|
|
88
|
+
// }
|
|
89
|
+
// if (topic === TOPIC_STATUS_USER + dataProfile.value?.id) {
|
|
90
|
+
// const index = listConversations.value.findIndex(
|
|
91
|
+
// (e) => e.receiver_id == Number(data?.customer_id)
|
|
92
|
+
// )
|
|
93
|
+
// if (index != -1) {
|
|
94
|
+
// listConversations.value[index].status = data.is_online ? 1 : 0
|
|
95
|
+
// }
|
|
96
|
+
// }
|
|
85
97
|
}
|
|
86
98
|
};
|
|
87
99
|
const getDataMqtt = useDebounce(() => {
|
|
@@ -131,6 +143,7 @@ export const useListConversations = (is_unknown, is_tenant) => {
|
|
|
131
143
|
if (listConversations.value[index].unread_count) {
|
|
132
144
|
readMessages(listConversations.value[index].id);
|
|
133
145
|
listConversations.value[index].unread_count = 0;
|
|
146
|
+
publishMessage(TOPIC_HOME[1] + dataProfile.value?.id, listConversations.value[index]);
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
};
|
package/dist/constant/mqtt.js
CHANGED
|
@@ -3,10 +3,11 @@ export const TOPIC_DETAIL_CALL = 'call/message/';
|
|
|
3
3
|
export const TOPIC_PLIVO_SMS = 'sms-inbound/';
|
|
4
4
|
export const TOPIC_STATUS_USER = 'user/status/';
|
|
5
5
|
export const TOPIC_HOME = [
|
|
6
|
-
'chat/conversation/update/',
|
|
6
|
+
// 'chat/conversation/update/',
|
|
7
|
+
// 'chat/conversation/read_message/',
|
|
8
|
+
// 'chat/conversation/update_list/',
|
|
9
|
+
'chat/conversation/update/sms-inbound/',
|
|
7
10
|
'chat/conversation/read_message/',
|
|
8
|
-
'chat/conversation/update_list/',
|
|
9
|
-
'chat/conversation/update/sms-inbound/'
|
|
10
11
|
];
|
|
11
12
|
// export CALL_STATE = {
|
|
12
13
|
// Offer: 'offer',
|