@phonghq/go-chat 1.0.55 → 1.0.57
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/assets/icons/call/IconClock.vue.d.ts +2 -0
- package/dist/assets/icons/call/IconClock.vue.js +22 -0
- package/dist/chat/App.vue.js +24 -7
- package/dist/chat/page/home/ChatList.vue.d.ts +4 -0
- package/dist/chat/page/home/ChatList.vue.js +12 -5
- package/dist/chat/page/home/ChatMessage.vue.d.ts +1 -0
- package/dist/chat/page/home/ChatMessage.vue.js +27 -7
- package/dist/chat/page/home/ChatMessageItem.vue.js +31 -16
- package/dist/chat/page/home/DropZone.vue.d.ts +13 -0
- package/dist/chat/page/home/DropZone.vue.js +130 -0
- package/dist/chat/page/home/Home.vue.d.ts +1 -0
- package/dist/chat/page/home/Home.vue.js +71 -20
- package/dist/chat/page/home/HomeHeader.vue.js +7 -5
- package/dist/chat/page/home/InputChat.vue.js +139 -70
- package/dist/chat/page/home/PhoneNumpad.vue.js +2 -0
- package/dist/components/chat/call/Calling.vue.js +76 -70
- package/dist/components/chat/call/TimeLeft.vue.d.ts +5 -0
- package/dist/components/chat/call/TimeLeft.vue.js +59 -0
- package/dist/composable/useInitData.js +2 -2
- package/dist/composable/useListConversations.d.ts +2 -0
- package/dist/composable/useListConversations.js +50 -11
- package/dist/composable/usePlivo.d.ts +1 -0
- package/dist/composable/usePlivo.js +31 -9
- package/dist/constant/mqtt.d.ts +1 -0
- package/dist/constant/mqtt.js +2 -0
- package/dist/go-chat.es.js +40714 -40469
- package/dist/go-chat.umd.js +23 -23
- package/dist/plugins/mqtt.js +5 -7
- package/dist/style.css +1 -1
- package/dist/types/chat/auth.d.ts +0 -1
- package/dist/types/chat/call.d.ts +1 -0
- package/dist/types/chat/call.js +1 -0
- package/dist/types/chat/global.d.ts +1 -0
- package/dist/types/message.d.ts +1 -0
- package/dist/utils/chat/store/auth.d.ts +0 -2
- package/dist/utils/chat/store/auth.js +7 -7
- package/dist/utils/chat/store/conversation.js +1 -1
- package/dist/utils/chat/store/message.d.ts +4 -0
- package/dist/utils/chat/store/message.js +4 -0
- package/dist/views/home/phone-numpad/PhoneNumpad.vue.js +3 -0
- package/package.json +1 -1
|
@@ -6,11 +6,13 @@ 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 { TOPIC_PLIVO_SMS } from '../../../constant/mqtt';
|
|
9
|
+
import { TOPIC_PLIVO_CALL, 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';
|
|
13
13
|
import { digibotId } from '../../../composable/useDigibot';
|
|
14
|
+
import dayjs from 'dayjs';
|
|
15
|
+
import { useDebounce } from '../../../utils/debounce';
|
|
14
16
|
const props = withDefaults(defineProps(), {});
|
|
15
17
|
const emit = defineEmits();
|
|
16
18
|
const MESSAGE_STORAGE_KEY = 'chat-message-';
|
|
@@ -24,19 +26,29 @@ const infoUser = shallowRef(null);
|
|
|
24
26
|
const listMessage = ref([]);
|
|
25
27
|
const chatMessageRef = ref(null);
|
|
26
28
|
const inputChatRef = ref(null);
|
|
27
|
-
onMounted(() => {
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
document.addEventListener('visibilitychange', handleVisibilitychange);
|
|
31
|
+
});
|
|
28
32
|
onUnmounted(() => {
|
|
33
|
+
document.removeEventListener('visibilitychange', handleVisibilitychange);
|
|
29
34
|
handleDisconnectMqtt();
|
|
30
35
|
});
|
|
36
|
+
const handleVisibilitychange = () => {
|
|
37
|
+
if (document.visibilityState === 'visible') {
|
|
38
|
+
handleGetMessage({ is_mqtt: true });
|
|
39
|
+
}
|
|
40
|
+
};
|
|
31
41
|
const handleConnectMqtt = async () => {
|
|
32
42
|
try {
|
|
33
43
|
await connectMqtt();
|
|
34
|
-
|
|
44
|
+
topic = TOPIC_PLIVO_CALL + infoUser.value?.conversation_id;
|
|
35
45
|
topic_plivo_chat = TOPIC_PLIVO_SMS + infoUser.value?.conversation_id;
|
|
36
46
|
// subscribeToTopic(topic)
|
|
37
47
|
subscribeToTopic(topic_plivo_chat);
|
|
48
|
+
subscribeToTopic(topic);
|
|
38
49
|
// addHandleMqttMessage('chat-home', topic, mqttMessageHandler)
|
|
39
50
|
addHandleMqttMessage('chat-home-1', topic_plivo_chat, mqttMessageHandler);
|
|
51
|
+
addHandleMqttMessage('chat-home-2', topic, mqttMessageHandler);
|
|
40
52
|
}
|
|
41
53
|
catch (error) {
|
|
42
54
|
console.error(error);
|
|
@@ -45,20 +57,23 @@ const handleConnectMqtt = async () => {
|
|
|
45
57
|
const handleDisconnectMqtt = async () => {
|
|
46
58
|
// unsubscribeFromTopic(topic)
|
|
47
59
|
await unsubscribeFromTopic(topic_plivo_chat);
|
|
60
|
+
await unsubscribeFromTopic(topic);
|
|
48
61
|
// removeHandleMqttMessage('chat-home')
|
|
49
62
|
removeHandleMqttMessage('chat-home-1');
|
|
63
|
+
removeHandleMqttMessage('chat-home-2');
|
|
50
64
|
};
|
|
51
65
|
const mqttMessageHandler = (topic, message) => {
|
|
52
|
-
// console.log(topic, message)
|
|
53
66
|
if ((infoUser.value?.id && message?.sender_id?.toString() == infoUser.value?.id?.toString()) ||
|
|
54
67
|
(infoUser.value?.id && message?.receiver_id?.toString() == infoUser.value?.id?.toString())) {
|
|
68
|
+
handleGetListMqtt();
|
|
55
69
|
const index = listMessage.value.findIndex((item) => item.id === message?.id);
|
|
56
70
|
if (index < 0) {
|
|
57
|
-
listMessage.value.unshift(
|
|
58
|
-
|
|
71
|
+
// listMessage.value.unshift(data)
|
|
72
|
+
listMessage.value.unshift({ ...message, local_id: message?.id });
|
|
59
73
|
}
|
|
60
74
|
else {
|
|
61
|
-
listMessage.value[index]
|
|
75
|
+
let data = listMessage.value[index];
|
|
76
|
+
listMessage.value[index] = { ...data, ...message };
|
|
62
77
|
}
|
|
63
78
|
chatMessageRef.value?.scrollBottom();
|
|
64
79
|
}
|
|
@@ -66,8 +81,11 @@ const mqttMessageHandler = (topic, message) => {
|
|
|
66
81
|
const handleGetMessage = async (option) => {
|
|
67
82
|
try {
|
|
68
83
|
const id = props.receiverId;
|
|
69
|
-
const params = {
|
|
70
|
-
|
|
84
|
+
const params = {
|
|
85
|
+
page: option?.resetList || option?.is_mqtt ? 1 : page,
|
|
86
|
+
receiver_id: props.receiverId
|
|
87
|
+
};
|
|
88
|
+
if (params.page <= 1 && !option?.is_mqtt) {
|
|
71
89
|
const cache = getCache(MESSAGE_STORAGE_KEY + id);
|
|
72
90
|
if (cache.data) {
|
|
73
91
|
listMessage.value = cache.data ?? [];
|
|
@@ -75,18 +93,23 @@ const handleGetMessage = async (option) => {
|
|
|
75
93
|
}
|
|
76
94
|
}
|
|
77
95
|
let res = await getMessage(params);
|
|
96
|
+
if (option?.is_mqtt) {
|
|
97
|
+
reconcileAndSortMessages(res.items);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
78
100
|
// res.items = res.items.reverse()
|
|
79
101
|
page = res._meta?.currentPage || 1;
|
|
80
102
|
pageCount = res._meta?.pageCount || 1;
|
|
103
|
+
const data = res.items?.map((e) => ({ ...e, local_id: e?.id }));
|
|
81
104
|
if (id == props.receiverId) {
|
|
82
105
|
if (page <= 1) {
|
|
83
|
-
listMessage.value =
|
|
106
|
+
listMessage.value = data;
|
|
84
107
|
chatMessageRef.value?.scrollBottom();
|
|
85
108
|
setCache(MESSAGE_STORAGE_KEY + id, res.items);
|
|
86
109
|
removeOldestCache(8, MESSAGE_STORAGE_KEY);
|
|
87
110
|
}
|
|
88
111
|
else {
|
|
89
|
-
listMessage.value.push(...
|
|
112
|
+
listMessage.value.push(...data);
|
|
90
113
|
// listMessage.value.unshift(...res.items)
|
|
91
114
|
}
|
|
92
115
|
}
|
|
@@ -135,16 +158,17 @@ const getData = async (data) => {
|
|
|
135
158
|
}
|
|
136
159
|
};
|
|
137
160
|
const updateMessageItem = (id, data) => {
|
|
138
|
-
const index = listMessage.value.findIndex((e) => e.
|
|
161
|
+
const index = listMessage.value.findIndex((e) => e.local_id == id);
|
|
139
162
|
if (index > -1) {
|
|
140
|
-
|
|
141
|
-
|
|
163
|
+
let item = listMessage.value[index];
|
|
164
|
+
item = { ...item, ...data };
|
|
165
|
+
listMessage.value[index] = item;
|
|
142
166
|
}
|
|
143
167
|
};
|
|
144
168
|
const handleSendMessage = async (data) => {
|
|
145
169
|
try {
|
|
146
170
|
// listMessage.value.push({ ...data, state: MessageState.Sending })
|
|
147
|
-
listMessage.value.unshift({ ...data, state: MessageState.Sending });
|
|
171
|
+
listMessage.value.unshift({ ...data, state: MessageState.Sending, local_id: data?.id });
|
|
148
172
|
await nextTick();
|
|
149
173
|
// publishMessage(topic, {
|
|
150
174
|
// ...data,
|
|
@@ -163,7 +187,7 @@ const handleSendMessage = async (data) => {
|
|
|
163
187
|
if (file_upload?.length) {
|
|
164
188
|
formData.append('url', file_upload[0]?.url ?? '');
|
|
165
189
|
}
|
|
166
|
-
await sendMessage(formData);
|
|
190
|
+
const res = await sendMessage(formData);
|
|
167
191
|
publishMessage(topic_plivo_chat, {
|
|
168
192
|
...data,
|
|
169
193
|
state: MessageState.Sent,
|
|
@@ -174,9 +198,16 @@ const handleSendMessage = async (data) => {
|
|
|
174
198
|
file_path: file_upload[0]?.url ?? ''
|
|
175
199
|
}
|
|
176
200
|
]
|
|
177
|
-
: []
|
|
201
|
+
: [],
|
|
202
|
+
id: res?.message?.id,
|
|
203
|
+
is_sms: res?.message?.is_sms,
|
|
204
|
+
local_id: data?.id
|
|
205
|
+
});
|
|
206
|
+
updateMessageItem(data.id, {
|
|
207
|
+
state: MessageState.Sent,
|
|
208
|
+
id: res?.message?.id,
|
|
209
|
+
is_sms: res?.message?.is_sms
|
|
178
210
|
});
|
|
179
|
-
updateMessageItem(data.id, { state: MessageState.Sent });
|
|
180
211
|
chatMessageRef.value?.scrollBottom();
|
|
181
212
|
publicTopicConversationUpdate({
|
|
182
213
|
message: data?.message ?? '',
|
|
@@ -212,6 +243,23 @@ const call = () => {
|
|
|
212
243
|
emit('call', infoUser.value);
|
|
213
244
|
}
|
|
214
245
|
};
|
|
246
|
+
const reconcileAndSortMessages = (serverMessages) => {
|
|
247
|
+
let currentMessages = [...listMessage.value];
|
|
248
|
+
serverMessages.forEach((serverMsg) => {
|
|
249
|
+
const index = currentMessages.findIndex((msg) => msg.id === serverMsg.id);
|
|
250
|
+
if (index !== -1) {
|
|
251
|
+
currentMessages[index] = {
|
|
252
|
+
...currentMessages[index],
|
|
253
|
+
...serverMsg
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
currentMessages.push(serverMsg);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
listMessage.value = currentMessages.sort((a, b) => dayjs(b.created_at).valueOf() - dayjs(a.created_at).valueOf());
|
|
261
|
+
};
|
|
262
|
+
const handleGetListMqtt = useDebounce(() => handleGetMessage({ is_mqtt: true }), 5000);
|
|
215
263
|
const __VLS_exposed = { getData, handleGetMessage, infoUser };
|
|
216
264
|
defineExpose(__VLS_exposed);
|
|
217
265
|
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
|
@@ -227,7 +275,7 @@ let __VLS_elements;
|
|
|
227
275
|
let __VLS_components;
|
|
228
276
|
let __VLS_directives;
|
|
229
277
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
230
|
-
...{ class: "h-full flex flex-col overflow-hidden" },
|
|
278
|
+
...{ class: "h-full flex flex-col overflow-hidden relative" },
|
|
231
279
|
});
|
|
232
280
|
/** @type {[typeof HomeHeader, ]} */ ;
|
|
233
281
|
// @ts-ignore
|
|
@@ -270,6 +318,7 @@ if (__VLS_ctx.listMessage?.length) {
|
|
|
270
318
|
...{ class: "grow" },
|
|
271
319
|
responsive: (__VLS_ctx.responsive),
|
|
272
320
|
showNewCustomer: (__VLS_ctx.page >= __VLS_ctx.pageCount),
|
|
321
|
+
isLoading: (__VLS_ctx.isLoading),
|
|
273
322
|
}));
|
|
274
323
|
const __VLS_9 = __VLS_8({
|
|
275
324
|
...{ 'onScrollTop': {} },
|
|
@@ -280,6 +329,7 @@ if (__VLS_ctx.listMessage?.length) {
|
|
|
280
329
|
...{ class: "grow" },
|
|
281
330
|
responsive: (__VLS_ctx.responsive),
|
|
282
331
|
showNewCustomer: (__VLS_ctx.page >= __VLS_ctx.pageCount),
|
|
332
|
+
isLoading: (__VLS_ctx.isLoading),
|
|
283
333
|
}, ...__VLS_functionalComponentArgsRest(__VLS_8));
|
|
284
334
|
let __VLS_11;
|
|
285
335
|
let __VLS_12;
|
|
@@ -290,7 +340,7 @@ if (__VLS_ctx.listMessage?.length) {
|
|
|
290
340
|
/** @type {typeof __VLS_ctx.chatMessageRef} */ ;
|
|
291
341
|
var __VLS_15 = {};
|
|
292
342
|
// @ts-ignore
|
|
293
|
-
[infoUser, responsive, call, reversedList, page, pageCount, handleScrollTop, chatMessageRef,];
|
|
343
|
+
[infoUser, responsive, call, reversedList, page, pageCount, isLoading, handleScrollTop, chatMessageRef,];
|
|
294
344
|
var __VLS_10;
|
|
295
345
|
}
|
|
296
346
|
else if (!__VLS_ctx.isLoading) {
|
|
@@ -357,6 +407,7 @@ if (__VLS_ctx.receiverId != __VLS_ctx.digibotId) {
|
|
|
357
407
|
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
358
408
|
/** @type {__VLS_StyleScopedClasses['flex-col']} */ ;
|
|
359
409
|
/** @type {__VLS_StyleScopedClasses['overflow-hidden']} */ ;
|
|
410
|
+
/** @type {__VLS_StyleScopedClasses['relative']} */ ;
|
|
360
411
|
/** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
|
|
361
412
|
/** @type {__VLS_StyleScopedClasses['grow']} */ ;
|
|
362
413
|
/** @type {__VLS_StyleScopedClasses['grow']} */ ;
|
|
@@ -25,7 +25,7 @@ const goToViewUser = () => {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
const handleActivePlivoSmsChange = async (is_active) => {
|
|
28
|
-
|
|
28
|
+
return;
|
|
29
29
|
try {
|
|
30
30
|
loading.value = true;
|
|
31
31
|
await activePlivoMode({ id: dataProfile.value?.id, is_sms: is_active ? 1 : 0 });
|
|
@@ -136,13 +136,15 @@ if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() &
|
|
|
136
136
|
...{ 'onClick': {} },
|
|
137
137
|
type: (__VLS_ctx.activePlivoSms ? 'success' : 'danger'),
|
|
138
138
|
loading: (__VLS_ctx.loading),
|
|
139
|
-
...{ class: "shrink-0 px-1 flex-center gap-2 text-white font-semibold w-9
|
|
139
|
+
...{ class: "shrink-0 px-1 flex-center gap-2 text-white font-semibold w-9 h-9" },
|
|
140
|
+
...{ class: ({ 'w-[140px]': __VLS_ctx.responsive != 'mobile' }) },
|
|
140
141
|
}));
|
|
141
142
|
const __VLS_12 = __VLS_11({
|
|
142
143
|
...{ 'onClick': {} },
|
|
143
144
|
type: (__VLS_ctx.activePlivoSms ? 'success' : 'danger'),
|
|
144
145
|
loading: (__VLS_ctx.loading),
|
|
145
|
-
...{ class: "shrink-0 px-1 flex-center gap-2 text-white font-semibold w-9
|
|
146
|
+
...{ class: "shrink-0 px-1 flex-center gap-2 text-white font-semibold w-9 h-9" },
|
|
147
|
+
...{ class: ({ 'w-[140px]': __VLS_ctx.responsive != 'mobile' }) },
|
|
146
148
|
}, ...__VLS_functionalComponentArgsRest(__VLS_11));
|
|
147
149
|
let __VLS_14;
|
|
148
150
|
let __VLS_15;
|
|
@@ -152,7 +154,7 @@ if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() &
|
|
|
152
154
|
return;
|
|
153
155
|
__VLS_ctx.handleActivePlivoSmsChange(!__VLS_ctx.activePlivoSms);
|
|
154
156
|
// @ts-ignore
|
|
155
|
-
[activePlivoSms, activePlivoSms, loading, handleActivePlivoSmsChange,];
|
|
157
|
+
[responsive, activePlivoSms, activePlivoSms, loading, handleActivePlivoSmsChange,];
|
|
156
158
|
} });
|
|
157
159
|
const { default: __VLS_17 } = __VLS_13.slots;
|
|
158
160
|
/** @type {[typeof IconSms, ]} */ ;
|
|
@@ -227,8 +229,8 @@ if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() &
|
|
|
227
229
|
/** @type {__VLS_StyleScopedClasses['text-white']} */ ;
|
|
228
230
|
/** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
|
|
229
231
|
/** @type {__VLS_StyleScopedClasses['w-9']} */ ;
|
|
230
|
-
/** @type {__VLS_StyleScopedClasses['md:w-[140px]']} */ ;
|
|
231
232
|
/** @type {__VLS_StyleScopedClasses['h-9']} */ ;
|
|
233
|
+
/** @type {__VLS_StyleScopedClasses['w-[140px]']} */ ;
|
|
232
234
|
/** @type {__VLS_StyleScopedClasses['hidden']} */ ;
|
|
233
235
|
/** @type {__VLS_StyleScopedClasses['md:block']} */ ;
|
|
234
236
|
/** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
|
|
@@ -6,30 +6,45 @@ import { useDebounce } from '../../../utils/debounce';
|
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import { DATE_FORMATS, TIME_ZONE_UTC } from '../../../constant/datetime';
|
|
8
8
|
import { dataProfile } from '../../../utils/chat/store/auth';
|
|
9
|
-
import {
|
|
9
|
+
import { ref, onMounted, onUnmounted } from 'vue';
|
|
10
10
|
import PopoverBase from '../../../components/chat/common/popover/PopoverBase.vue';
|
|
11
|
-
import
|
|
11
|
+
import IconCloseCircle from '../../../assets/icons/global/IconCloseCircle.vue';
|
|
12
|
+
import DropZone from '@/chat/page/home/DropZone.vue';
|
|
12
13
|
const props = withDefaults(defineProps(), {});
|
|
13
14
|
const emit = defineEmits();
|
|
14
15
|
const ChatModeOptions = [
|
|
15
16
|
{ value: '0', label: 'Go Chat' },
|
|
16
17
|
{ value: '1', label: 'Go sms' }
|
|
17
18
|
];
|
|
18
|
-
const modeLabel = computed(() => ChatModeOptions.find((v) => v.value === mode.value)?.label ?? '')
|
|
19
|
+
// const modeLabel = computed(() => ChatModeOptions.find((v) => v.value === mode.value)?.label ?? '')
|
|
19
20
|
const keyword = defineModel();
|
|
20
21
|
let chatId = 1;
|
|
22
|
+
let dragCounter = 0;
|
|
23
|
+
onMounted(() => { });
|
|
24
|
+
onUnmounted(() => { });
|
|
21
25
|
const refInputImage = ref(null);
|
|
22
|
-
const isLoadingImage = ref([])
|
|
26
|
+
// const isLoadingImage = ref<any>([])
|
|
23
27
|
const activePlivoSms = ref(false);
|
|
24
28
|
const loading = ref(false);
|
|
25
29
|
const chatInputRef = ref(null);
|
|
26
30
|
const emojiOpen = ref(false);
|
|
27
|
-
const mode = ref('0')
|
|
31
|
+
// const mode = ref('0')
|
|
32
|
+
const dropFile = ref(null);
|
|
33
|
+
const dropFileLink = ref('');
|
|
34
|
+
const removeDropFile = () => {
|
|
35
|
+
dropFileLink.value = '';
|
|
36
|
+
dropFile.value = null;
|
|
37
|
+
};
|
|
28
38
|
const handleSendMessage = async (type) => {
|
|
29
39
|
const tempId = Date.now();
|
|
30
40
|
let messageContent = '';
|
|
31
41
|
let attachments = [];
|
|
32
|
-
if (
|
|
42
|
+
if (dropFile.value) {
|
|
43
|
+
attachments = [
|
|
44
|
+
{ file_name: String(tempId), file_path: dropFileLink.value, file_local: dropFile.value }
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
else if (type == 'message') {
|
|
33
48
|
if (!keyword.value)
|
|
34
49
|
return;
|
|
35
50
|
messageContent = keyword.value;
|
|
@@ -43,14 +58,14 @@ const handleSendMessage = async (type) => {
|
|
|
43
58
|
const file_path = URL.createObjectURL(file);
|
|
44
59
|
attachments = [{ file_name: String(tempId), file_path, file_local: file }];
|
|
45
60
|
}
|
|
46
|
-
|
|
47
|
-
// chatInputRef.value.style.height = 'auto'
|
|
61
|
+
clearInput();
|
|
48
62
|
chatId++;
|
|
49
63
|
const id = props.data?.id.toString() + '-' + chatId + '-' + Date.now();
|
|
50
64
|
const data = {
|
|
51
65
|
conversation_id: props.data?.conversation_id,
|
|
52
66
|
created_at: dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']),
|
|
53
67
|
id,
|
|
68
|
+
local_id: id,
|
|
54
69
|
message: messageContent,
|
|
55
70
|
receiver_id: props.data?.id || 0,
|
|
56
71
|
sender_id: dataProfile.value?.id,
|
|
@@ -76,17 +91,6 @@ const onSelectEmoji = (value) => {
|
|
|
76
91
|
// emojiOpen.value = false
|
|
77
92
|
// chatInputRef.value?.focus?.()
|
|
78
93
|
};
|
|
79
|
-
const handleActivePlivoSmsChange = async (is_active) => {
|
|
80
|
-
try {
|
|
81
|
-
loading.value = true;
|
|
82
|
-
await activePlivoMode({ id: dataProfile.value?.id, is_sms: is_active ? 1 : 0 });
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
activePlivoSms.value = !is_active;
|
|
86
|
-
console.log(e);
|
|
87
|
-
}
|
|
88
|
-
loading.value = false;
|
|
89
|
-
};
|
|
90
94
|
const setInputHeight = (e) => {
|
|
91
95
|
const el = chatInputRef.value;
|
|
92
96
|
el.style.height = 'auto';
|
|
@@ -108,7 +112,9 @@ const handleInput = () => {
|
|
|
108
112
|
};
|
|
109
113
|
const clearInput = () => {
|
|
110
114
|
keyword.value = '';
|
|
115
|
+
removeDropFile();
|
|
111
116
|
};
|
|
117
|
+
const newline = () => { };
|
|
112
118
|
const __VLS_exposed = { clearInput };
|
|
113
119
|
defineExpose(__VLS_exposed);
|
|
114
120
|
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
|
@@ -133,55 +139,91 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
|
133
139
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
134
140
|
...{ class: "relative grow" },
|
|
135
141
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
142
|
+
if (__VLS_ctx.dropFileLink) {
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
[dropFileLink,];
|
|
145
|
+
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
146
|
+
...{ class: "border border-chat-haze-200 rounded-xl p-4" },
|
|
147
|
+
});
|
|
148
|
+
__VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
149
|
+
...{ onClick: (...[$event]) => {
|
|
150
|
+
if (!(__VLS_ctx.dropFileLink))
|
|
151
|
+
return;
|
|
152
|
+
__VLS_ctx.removeDropFile();
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
[removeDropFile,];
|
|
155
|
+
} },
|
|
156
|
+
...{ class: "absolute top-4 right-4" },
|
|
157
|
+
});
|
|
158
|
+
/** @type {[typeof IconCloseCircle, ]} */ ;
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
const __VLS_0 = __VLS_asFunctionalComponent(IconCloseCircle, new IconCloseCircle({}));
|
|
161
|
+
const __VLS_1 = __VLS_0({}, ...__VLS_functionalComponentArgsRest(__VLS_0));
|
|
162
|
+
__VLS_asFunctionalElement(__VLS_elements.img)({
|
|
163
|
+
...{ class: "max-h-[150px] w-auto" },
|
|
164
|
+
src: (__VLS_ctx.dropFileLink),
|
|
165
|
+
});
|
|
166
|
+
// @ts-ignore
|
|
167
|
+
[dropFileLink,];
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
__VLS_asFunctionalElement(__VLS_elements.textarea)({
|
|
171
|
+
...{ onKeydown: (...[$event]) => {
|
|
172
|
+
if (!!(__VLS_ctx.dropFileLink))
|
|
173
|
+
return;
|
|
174
|
+
__VLS_ctx.handleSendMessage('message');
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
[handleSendMessage,];
|
|
177
|
+
} },
|
|
178
|
+
...{ onKeydown: (__VLS_ctx.newline) },
|
|
179
|
+
...{ onFocus: (...[$event]) => {
|
|
180
|
+
if (!!(__VLS_ctx.dropFileLink))
|
|
181
|
+
return;
|
|
182
|
+
__VLS_ctx.handleInput();
|
|
183
|
+
// @ts-ignore
|
|
184
|
+
[newline, handleInput,];
|
|
185
|
+
} },
|
|
186
|
+
...{ onInput: (...[$event]) => {
|
|
187
|
+
if (!!(__VLS_ctx.dropFileLink))
|
|
188
|
+
return;
|
|
189
|
+
__VLS_ctx.setInputHeight($event);
|
|
190
|
+
// @ts-ignore
|
|
191
|
+
[setInputHeight,];
|
|
192
|
+
} },
|
|
193
|
+
...{ 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]" },
|
|
194
|
+
ref: "chatInputRef",
|
|
195
|
+
rows: "1",
|
|
196
|
+
placeholder: "Send Message",
|
|
197
|
+
value: (__VLS_ctx.keyword),
|
|
198
|
+
});
|
|
199
|
+
/** @type {typeof __VLS_ctx.chatInputRef} */ ;
|
|
200
|
+
// @ts-ignore
|
|
201
|
+
[keyword, chatInputRef,];
|
|
202
|
+
}
|
|
161
203
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
162
204
|
...{ class: "flex gap-2 -translate-y-2" },
|
|
163
205
|
});
|
|
164
|
-
if (!__VLS_ctx.dataProfile?.is_sms_active) {
|
|
206
|
+
if (!__VLS_ctx.dataProfile?.is_sms_active && !__VLS_ctx.dropFileLink) {
|
|
165
207
|
// @ts-ignore
|
|
166
|
-
[dataProfile,];
|
|
208
|
+
[dropFileLink, dataProfile,];
|
|
167
209
|
/** @type {[typeof PopoverBase, typeof PopoverBase, ]} */ ;
|
|
168
210
|
// @ts-ignore
|
|
169
|
-
const
|
|
211
|
+
const __VLS_4 = __VLS_asFunctionalComponent(PopoverBase, new PopoverBase({
|
|
170
212
|
open: (__VLS_ctx.emojiOpen),
|
|
171
213
|
align: "end",
|
|
172
214
|
side: "top",
|
|
173
215
|
}));
|
|
174
|
-
const
|
|
216
|
+
const __VLS_5 = __VLS_4({
|
|
175
217
|
open: (__VLS_ctx.emojiOpen),
|
|
176
218
|
align: "end",
|
|
177
219
|
side: "top",
|
|
178
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
179
|
-
const { default:
|
|
220
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_4));
|
|
221
|
+
const { default: __VLS_7 } = __VLS_6.slots;
|
|
180
222
|
// @ts-ignore
|
|
181
223
|
[emojiOpen,];
|
|
182
224
|
__VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
183
225
|
...{ onClick: (...[$event]) => {
|
|
184
|
-
if (!(!__VLS_ctx.dataProfile?.is_sms_active))
|
|
226
|
+
if (!(!__VLS_ctx.dataProfile?.is_sms_active && !__VLS_ctx.dropFileLink))
|
|
185
227
|
return;
|
|
186
228
|
__VLS_ctx.emojiOpen = !__VLS_ctx.emojiOpen;
|
|
187
229
|
// @ts-ignore
|
|
@@ -190,63 +232,65 @@ if (!__VLS_ctx.dataProfile?.is_sms_active) {
|
|
|
190
232
|
...{ class: "h-11 w-8" },
|
|
191
233
|
});
|
|
192
234
|
{
|
|
193
|
-
const { content:
|
|
194
|
-
const
|
|
235
|
+
const { content: __VLS_8 } = __VLS_6.slots;
|
|
236
|
+
const __VLS_9 = {}.EmojiPicker;
|
|
195
237
|
/** @type {[typeof __VLS_components.EmojiPicker, typeof __VLS_components.emojiPicker, ]} */ ;
|
|
196
238
|
// @ts-ignore
|
|
197
239
|
EmojiPicker;
|
|
198
240
|
// @ts-ignore
|
|
199
|
-
const
|
|
241
|
+
const __VLS_10 = __VLS_asFunctionalComponent(__VLS_9, new __VLS_9({
|
|
200
242
|
...{ 'onSelect': {} },
|
|
201
243
|
...{ class: "!w-[300px]" },
|
|
202
244
|
native: (true),
|
|
203
245
|
offset: (2),
|
|
204
246
|
hideSearch: true,
|
|
205
247
|
}));
|
|
206
|
-
const
|
|
248
|
+
const __VLS_11 = __VLS_10({
|
|
207
249
|
...{ 'onSelect': {} },
|
|
208
250
|
...{ class: "!w-[300px]" },
|
|
209
251
|
native: (true),
|
|
210
252
|
offset: (2),
|
|
211
253
|
hideSearch: true,
|
|
212
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
213
|
-
let
|
|
214
|
-
let
|
|
215
|
-
const
|
|
254
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_10));
|
|
255
|
+
let __VLS_13;
|
|
256
|
+
let __VLS_14;
|
|
257
|
+
const __VLS_15 = ({ select: {} },
|
|
216
258
|
{ onSelect: (__VLS_ctx.onSelectEmoji) });
|
|
217
259
|
// @ts-ignore
|
|
218
260
|
[onSelectEmoji,];
|
|
219
|
-
var
|
|
261
|
+
var __VLS_12;
|
|
220
262
|
}
|
|
221
|
-
var
|
|
263
|
+
var __VLS_6;
|
|
222
264
|
}
|
|
223
265
|
if (!__VLS_ctx.dataProfile?.is_sms_active) {
|
|
224
266
|
// @ts-ignore
|
|
225
267
|
[dataProfile,];
|
|
226
|
-
const
|
|
268
|
+
const __VLS_17 = {}.EmojiPicker;
|
|
227
269
|
/** @type {[typeof __VLS_components.EmojiPicker, typeof __VLS_components.emojiPicker, ]} */ ;
|
|
228
270
|
// @ts-ignore
|
|
229
271
|
EmojiPicker;
|
|
230
272
|
// @ts-ignore
|
|
231
|
-
const
|
|
273
|
+
const __VLS_18 = __VLS_asFunctionalComponent(__VLS_17, new __VLS_17({
|
|
232
274
|
...{ class: "opacity-0 pointer-events-none absolute" },
|
|
233
275
|
native: (true),
|
|
234
276
|
offset: (2),
|
|
235
277
|
hideSearch: true,
|
|
236
278
|
}));
|
|
237
|
-
const
|
|
279
|
+
const __VLS_19 = __VLS_18({
|
|
238
280
|
...{ class: "opacity-0 pointer-events-none absolute" },
|
|
239
281
|
native: (true),
|
|
240
282
|
offset: (2),
|
|
241
283
|
hideSearch: true,
|
|
242
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
284
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_18));
|
|
243
285
|
}
|
|
244
286
|
__VLS_asFunctionalElement(__VLS_elements.label, __VLS_elements.label)({
|
|
245
287
|
...{ class: "cursor-pointer relative" },
|
|
246
288
|
});
|
|
247
|
-
__VLS_asFunctionalDirective(__VLS_directives.vShow)(null, { ...__VLS_directiveBindingRestFields, value: (!(__VLS_ctx.keyword != '' && __VLS_ctx.responsive == 'mobile') &&
|
|
289
|
+
__VLS_asFunctionalDirective(__VLS_directives.vShow)(null, { ...__VLS_directiveBindingRestFields, value: (!(__VLS_ctx.keyword != '' && __VLS_ctx.responsive == 'mobile') &&
|
|
290
|
+
!__VLS_ctx.dataProfile?.is_sms_active &&
|
|
291
|
+
!__VLS_ctx.dropFileLink) }, null, null);
|
|
248
292
|
// @ts-ignore
|
|
249
|
-
[keyword, dataProfile, responsive,];
|
|
293
|
+
[dropFileLink, keyword, dataProfile, responsive,];
|
|
250
294
|
__VLS_asFunctionalElement(__VLS_elements.input)({
|
|
251
295
|
...{ onChange: (__VLS_ctx.handleFileUpload) },
|
|
252
296
|
type: "file",
|
|
@@ -283,12 +327,28 @@ __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
|
283
327
|
});
|
|
284
328
|
/** @type {[typeof IconPlan, ]} */ ;
|
|
285
329
|
// @ts-ignore
|
|
286
|
-
const
|
|
330
|
+
const __VLS_22 = __VLS_asFunctionalComponent(IconPlan, new IconPlan({
|
|
287
331
|
color: "#fff",
|
|
288
332
|
}));
|
|
289
|
-
const
|
|
333
|
+
const __VLS_23 = __VLS_22({
|
|
290
334
|
color: "#fff",
|
|
291
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
335
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_22));
|
|
336
|
+
if (!__VLS_ctx.dataProfile?.is_sms_active) {
|
|
337
|
+
// @ts-ignore
|
|
338
|
+
[dataProfile,];
|
|
339
|
+
/** @type {[typeof DropZone, ]} */ ;
|
|
340
|
+
// @ts-ignore
|
|
341
|
+
const __VLS_26 = __VLS_asFunctionalComponent(DropZone, new DropZone({
|
|
342
|
+
link: (__VLS_ctx.dropFileLink),
|
|
343
|
+
file: (__VLS_ctx.dropFile),
|
|
344
|
+
}));
|
|
345
|
+
const __VLS_27 = __VLS_26({
|
|
346
|
+
link: (__VLS_ctx.dropFileLink),
|
|
347
|
+
file: (__VLS_ctx.dropFile),
|
|
348
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_26));
|
|
349
|
+
// @ts-ignore
|
|
350
|
+
[dropFileLink, dropFile,];
|
|
351
|
+
}
|
|
292
352
|
/** @type {__VLS_StyleScopedClasses['z-10']} */ ;
|
|
293
353
|
/** @type {__VLS_StyleScopedClasses['layout-shadow']} */ ;
|
|
294
354
|
/** @type {__VLS_StyleScopedClasses['border-t']} */ ;
|
|
@@ -299,6 +359,15 @@ const __VLS_19 = __VLS_18({
|
|
|
299
359
|
/** @type {__VLS_StyleScopedClasses['h-max']} */ ;
|
|
300
360
|
/** @type {__VLS_StyleScopedClasses['relative']} */ ;
|
|
301
361
|
/** @type {__VLS_StyleScopedClasses['grow']} */ ;
|
|
362
|
+
/** @type {__VLS_StyleScopedClasses['border']} */ ;
|
|
363
|
+
/** @type {__VLS_StyleScopedClasses['border-chat-haze-200']} */ ;
|
|
364
|
+
/** @type {__VLS_StyleScopedClasses['rounded-xl']} */ ;
|
|
365
|
+
/** @type {__VLS_StyleScopedClasses['p-4']} */ ;
|
|
366
|
+
/** @type {__VLS_StyleScopedClasses['absolute']} */ ;
|
|
367
|
+
/** @type {__VLS_StyleScopedClasses['top-4']} */ ;
|
|
368
|
+
/** @type {__VLS_StyleScopedClasses['right-4']} */ ;
|
|
369
|
+
/** @type {__VLS_StyleScopedClasses['max-h-[150px]']} */ ;
|
|
370
|
+
/** @type {__VLS_StyleScopedClasses['w-auto']} */ ;
|
|
302
371
|
/** @type {__VLS_StyleScopedClasses['text-[14px]']} */ ;
|
|
303
372
|
/** @type {__VLS_StyleScopedClasses['sm:text-base']} */ ;
|
|
304
373
|
/** @type {__VLS_StyleScopedClasses['w-full']} */ ;
|
|
@@ -65,10 +65,12 @@ else {
|
|
|
65
65
|
const __VLS_8 = __VLS_asFunctionalComponent(DrawerBaseCustom, new DrawerBaseCustom({
|
|
66
66
|
ref: "drawerVisibleRef",
|
|
67
67
|
responsive: (__VLS_ctx.responsive),
|
|
68
|
+
absolute: true,
|
|
68
69
|
}));
|
|
69
70
|
const __VLS_9 = __VLS_8({
|
|
70
71
|
ref: "drawerVisibleRef",
|
|
71
72
|
responsive: (__VLS_ctx.responsive),
|
|
73
|
+
absolute: true,
|
|
72
74
|
}, ...__VLS_functionalComponentArgsRest(__VLS_8));
|
|
73
75
|
/** @type {typeof __VLS_ctx.drawerVisibleRef} */ ;
|
|
74
76
|
var __VLS_11 = {};
|