@phonghq/go-chat 1.0.24 → 1.0.26
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/IconCloseCircle.vue.d.ts +2 -0
- package/dist/chat/page/home/ChatList.vue.d.ts +5 -2
- package/dist/chat/page/home/ChatMessage.vue.d.ts +2 -0
- package/dist/chat/page/home/ChatMessageItem.vue.d.ts +10 -3
- package/dist/chat/page/home/Home.vue.d.ts +1 -0
- package/dist/chat/page/setting/Setting.vue.d.ts +2 -0
- package/dist/components/chat/ScrollEvent/ScrollEvent.vue.d.ts +1 -0
- package/dist/components/chat/call/Calling.vue.d.ts +2 -2
- package/dist/components/chat/select/SelectBase.vue.d.ts +2 -0
- package/dist/components/common/button/ButtonBase.vue.d.ts +1 -1
- package/dist/components/common/drawer/DrawerBase.vue.d.ts +1 -1
- package/dist/components/common/drawer/DrawerBaseCustom.vue.d.ts +1 -0
- package/dist/composable/useCallHelper.d.ts +2 -0
- package/dist/composable/useListConversations.d.ts +4 -2
- package/dist/go-chat.es.js +10491 -10554
- package/dist/go-chat.umd.js +13 -13
- package/dist/style.css +1 -1
- package/dist/test/assets/icons/IconCloseCircle.vue.js +36 -0
- package/dist/test/chat/App.vue.js +98 -21
- package/dist/test/chat/page/customer-detail/CustomerDetail.vue.js +0 -3
- package/dist/test/chat/page/home/ChatList.vue.js +20 -34
- package/dist/test/chat/page/home/ChatMessage.vue.js +32 -22
- package/dist/test/chat/page/home/ChatMessageItem.vue.js +51 -37
- package/dist/test/chat/page/home/Home.vue.js +26 -61
- package/dist/test/chat/page/home/HomeHeader.vue.js +0 -6
- package/dist/test/chat/page/home/InputChat.vue.js +0 -1
- package/dist/test/chat/page/setting/Setting.vue.js +125 -0
- package/dist/test/components/chat/call/Calling.vue.js +22 -6
- package/dist/test/components/chat/select/SelectBase.vue.js +13 -3
- package/dist/test/components/common/drawer/DrawerBaseCustom.vue.js +9 -4
- package/dist/test/composable/useDigibot.js +2 -1
- package/dist/test/composable/useInitData.js +0 -6
- package/dist/test/composable/useListConversations.js +6 -4
- package/dist/test/composable/usePlivo.js +9 -3
- package/dist/test/types/chat/call.js +3 -1
- package/dist/test/utils/chat/auth.js +4 -3
- package/dist/test/utils/chat/conversation.js +57 -0
- package/dist/types/chat/call.d.ts +2 -0
- package/dist/types/chat/global.d.ts +1 -0
- package/dist/types/conversation.d.ts +2 -1
- package/dist/types/message.d.ts +1 -0
- package/dist/utils/chat/conversation.d.ts +7 -0
- package/dist/utils/chat/user.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="C:/phonghq/go-chat-v2/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
|
|
2
|
+
import { dataProfile } from '../../../utils/chat/auth';
|
|
2
3
|
import { nextTick, ref } from 'vue';
|
|
3
4
|
import ScrollEvent from '../../../components/chat/ScrollEvent/ScrollEvent.vue';
|
|
4
|
-
import { MessageState } from '../../../constant/message';
|
|
5
5
|
import NewCustomer from '../../../chat/page/home/NewCustomer.vue';
|
|
6
6
|
import ChatMessageItem from '../../../chat/page/home/ChatMessageItem.vue';
|
|
7
|
+
import dayjs from 'dayjs';
|
|
7
8
|
const props = withDefaults(defineProps(), {});
|
|
8
9
|
const emit = defineEmits();
|
|
9
10
|
const scrollEventRef = ref(null);
|
|
@@ -25,6 +26,13 @@ const isEndMessage = (index) => {
|
|
|
25
26
|
return true;
|
|
26
27
|
return props.message[index + 1].sender_id !== props.message[index].sender_id;
|
|
27
28
|
};
|
|
29
|
+
const isChatFinished = (index) => {
|
|
30
|
+
if (isEndMessage(index))
|
|
31
|
+
return true;
|
|
32
|
+
const time1 = dayjs(props.message[index].created_at);
|
|
33
|
+
const time2 = dayjs(props.message[index + 1].created_at);
|
|
34
|
+
return time2.diff(time1, 'minute') > 10;
|
|
35
|
+
};
|
|
28
36
|
const handleScrollTop = () => {
|
|
29
37
|
emit('scrollTop');
|
|
30
38
|
};
|
|
@@ -34,23 +42,6 @@ const hideScrollEvent = () => {
|
|
|
34
42
|
const fixedScroll = () => {
|
|
35
43
|
scrollEventRef.value?.fixedScroll();
|
|
36
44
|
};
|
|
37
|
-
const getMessageStateText = (item) => {
|
|
38
|
-
const state = item.state;
|
|
39
|
-
switch (state) {
|
|
40
|
-
case MessageState.Sending:
|
|
41
|
-
return 'Sending...';
|
|
42
|
-
case MessageState.Uploading:
|
|
43
|
-
return 'Uploading...';
|
|
44
|
-
case MessageState.Sent:
|
|
45
|
-
return '';
|
|
46
|
-
case MessageState.Read:
|
|
47
|
-
return 'Seen';
|
|
48
|
-
case MessageState.Failed:
|
|
49
|
-
return item.error || 'Message failed';
|
|
50
|
-
default:
|
|
51
|
-
return '';
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
45
|
const __VLS_exposed = { scrollBottom, hideScrollEvent, fixedScroll };
|
|
55
46
|
defineExpose(__VLS_exposed);
|
|
56
47
|
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
|
@@ -97,7 +88,7 @@ if (__VLS_ctx.showNewCustomer) {
|
|
|
97
88
|
// @ts-ignore
|
|
98
89
|
[showNewCustomer,];
|
|
99
90
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
100
|
-
...{ class: "shrink-0 h-[500px]" },
|
|
91
|
+
...{ class: "shrink-0 h-[500px] chat-padding-page" },
|
|
101
92
|
});
|
|
102
93
|
/** @type {[typeof NewCustomer, ]} */ ;
|
|
103
94
|
// @ts-ignore
|
|
@@ -116,27 +107,45 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
|
116
107
|
...{ class: "chat-padding-page" },
|
|
117
108
|
});
|
|
118
109
|
for (const [item, index] of __VLS_getVForSourceType((__VLS_ctx.message))) {
|
|
119
|
-
(item.id);
|
|
120
110
|
// @ts-ignore
|
|
121
111
|
[message,];
|
|
122
112
|
/** @type {[typeof ChatMessageItem, ]} */ ;
|
|
123
113
|
// @ts-ignore
|
|
124
114
|
const __VLS_13 = __VLS_asFunctionalComponent(ChatMessageItem, new ChatMessageItem({
|
|
115
|
+
...{ 'onCallAgain': {} },
|
|
125
116
|
message: (item),
|
|
126
117
|
index: (index),
|
|
127
118
|
listMessage: (__VLS_ctx.message),
|
|
128
119
|
responsive: (__VLS_ctx.responsive),
|
|
120
|
+
isMyMessage: (item.sender_id == __VLS_ctx.dataProfile?.id),
|
|
129
121
|
data: (__VLS_ctx.data),
|
|
122
|
+
shouldShowAvatar: (__VLS_ctx.shouldShowAvatar(index)),
|
|
123
|
+
isLastMessage: (index == __VLS_ctx.message.length - 1),
|
|
124
|
+
isEndMessage: (__VLS_ctx.isEndMessage(index)),
|
|
125
|
+
isChatFinished: (__VLS_ctx.isChatFinished(index)),
|
|
130
126
|
}));
|
|
131
127
|
const __VLS_14 = __VLS_13({
|
|
128
|
+
...{ 'onCallAgain': {} },
|
|
132
129
|
message: (item),
|
|
133
130
|
index: (index),
|
|
134
131
|
listMessage: (__VLS_ctx.message),
|
|
135
132
|
responsive: (__VLS_ctx.responsive),
|
|
133
|
+
isMyMessage: (item.sender_id == __VLS_ctx.dataProfile?.id),
|
|
136
134
|
data: (__VLS_ctx.data),
|
|
135
|
+
shouldShowAvatar: (__VLS_ctx.shouldShowAvatar(index)),
|
|
136
|
+
isLastMessage: (index == __VLS_ctx.message.length - 1),
|
|
137
|
+
isEndMessage: (__VLS_ctx.isEndMessage(index)),
|
|
138
|
+
isChatFinished: (__VLS_ctx.isChatFinished(index)),
|
|
137
139
|
}, ...__VLS_functionalComponentArgsRest(__VLS_13));
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
let __VLS_16;
|
|
141
|
+
let __VLS_17;
|
|
142
|
+
const __VLS_18 = ({ callAgain: {} },
|
|
143
|
+
{ onCallAgain: (...[$event]) => {
|
|
144
|
+
__VLS_ctx.emit('callBack');
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
[data, message, message, responsive, dataProfile, shouldShowAvatar, isEndMessage, isChatFinished, emit,];
|
|
147
|
+
} });
|
|
148
|
+
var __VLS_15;
|
|
140
149
|
}
|
|
141
150
|
var __VLS_2;
|
|
142
151
|
/** @type {__VLS_StyleScopedClasses['relative']} */ ;
|
|
@@ -148,6 +157,7 @@ var __VLS_2;
|
|
|
148
157
|
/** @type {__VLS_StyleScopedClasses['overflow-auto']} */ ;
|
|
149
158
|
/** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
|
|
150
159
|
/** @type {__VLS_StyleScopedClasses['h-[500px]']} */ ;
|
|
160
|
+
/** @type {__VLS_StyleScopedClasses['chat-padding-page']} */ ;
|
|
151
161
|
/** @type {__VLS_StyleScopedClasses['h-full']} */ ;
|
|
152
162
|
/** @type {__VLS_StyleScopedClasses['chat-padding-page']} */ ;
|
|
153
163
|
// @ts-ignore
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/// <reference types="C:/phonghq/go-chat-v2/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
|
|
2
2
|
import Avatar from '../../../components/chat/customer/Avatar.vue';
|
|
3
|
-
import { dataProfile } from '../../../utils/chat/auth';
|
|
4
3
|
import { computed, nextTick } from 'vue';
|
|
5
4
|
import { MessageState } from '../../../constant/message';
|
|
6
5
|
import IconPhoneCancel from '../../../assets/icons/call/IconPhoneCancel.vue';
|
|
7
6
|
import { PLIVO_CALL_STATUS } from '../../../types/chat/call';
|
|
8
7
|
import IconPhone from '../../../assets/icons/customer-detail/IconPhone.vue';
|
|
8
|
+
import dayjs from 'dayjs';
|
|
9
|
+
import { DATE_FORMATS } from '../../../constant/datetime';
|
|
9
10
|
const props = withDefaults(defineProps(), {});
|
|
10
|
-
const
|
|
11
|
+
const emit = defineEmits();
|
|
11
12
|
const callTitle = computed(() => {
|
|
12
|
-
if (isMyMessage
|
|
13
|
+
if (props.isMyMessage) {
|
|
13
14
|
if (props.message?.call_status == PLIVO_CALL_STATUS.CONNECT_FAILED) {
|
|
14
15
|
return 'Call canceled';
|
|
15
16
|
}
|
|
@@ -21,7 +22,11 @@ const callTitle = computed(() => {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
|
-
if (props.message?.call_status == PLIVO_CALL_STATUS.CONNECT_FAILED
|
|
25
|
+
if (props.message?.call_status == PLIVO_CALL_STATUS.CONNECT_FAILED ||
|
|
26
|
+
props.message?.call_status == PLIVO_CALL_STATUS.TIME_OUT ||
|
|
27
|
+
props.message?.call_status == PLIVO_CALL_STATUS.CANCEL ||
|
|
28
|
+
props.message?.call_status == PLIVO_CALL_STATUS.NO_ANSWER ||
|
|
29
|
+
props.message?.call_status == PLIVO_CALL_STATUS.BUSY) {
|
|
25
30
|
return 'Call missed';
|
|
26
31
|
}
|
|
27
32
|
else if (props.message?.call_status == PLIVO_CALL_STATUS.CALL_END) {
|
|
@@ -43,16 +48,6 @@ const getCallDuration = (seconds) => {
|
|
|
43
48
|
const secs = seconds % 60;
|
|
44
49
|
return `${min} min${min > 1 ? 's' : ''} ${secs} sec`;
|
|
45
50
|
};
|
|
46
|
-
const shouldShowAvatar = (index) => {
|
|
47
|
-
if (index === 0)
|
|
48
|
-
return true;
|
|
49
|
-
return props.listMessage[index - 1].sender_id !== props.listMessage[index].sender_id;
|
|
50
|
-
};
|
|
51
|
-
const isEndMessage = (index) => {
|
|
52
|
-
if (props.listMessage?.length == index + 1)
|
|
53
|
-
return true;
|
|
54
|
-
return props.listMessage[index + 1].sender_id !== props.listMessage[index].sender_id;
|
|
55
|
-
};
|
|
56
51
|
const getMessageStateText = (item) => {
|
|
57
52
|
const state = item.state;
|
|
58
53
|
switch (state) {
|
|
@@ -77,6 +72,7 @@ const __VLS_ctx = {
|
|
|
77
72
|
...{},
|
|
78
73
|
...{},
|
|
79
74
|
...{},
|
|
75
|
+
...{},
|
|
80
76
|
};
|
|
81
77
|
let __VLS_elements;
|
|
82
78
|
let __VLS_components;
|
|
@@ -84,22 +80,22 @@ let __VLS_directives;
|
|
|
84
80
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
85
81
|
...{ class: "flex items-end mt-2" },
|
|
86
82
|
...{ class: ({
|
|
87
|
-
'mt-4': __VLS_ctx.shouldShowAvatar
|
|
83
|
+
'mt-4': __VLS_ctx.shouldShowAvatar,
|
|
88
84
|
'flex-col justify-end pl-[60px]': __VLS_ctx.isMyMessage,
|
|
89
85
|
'gap-2': !__VLS_ctx.isMyMessage
|
|
90
86
|
}) },
|
|
91
87
|
});
|
|
92
88
|
// @ts-ignore
|
|
93
|
-
[shouldShowAvatar,
|
|
89
|
+
[shouldShowAvatar, isMyMessage, isMyMessage,];
|
|
94
90
|
if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
95
91
|
// @ts-ignore
|
|
96
92
|
[message, MessageState,];
|
|
97
93
|
if (!__VLS_ctx.isMyMessage) {
|
|
98
94
|
// @ts-ignore
|
|
99
95
|
[isMyMessage,];
|
|
100
|
-
if (__VLS_ctx.shouldShowAvatar
|
|
96
|
+
if (__VLS_ctx.shouldShowAvatar) {
|
|
101
97
|
// @ts-ignore
|
|
102
|
-
[shouldShowAvatar,
|
|
98
|
+
[shouldShowAvatar,];
|
|
103
99
|
/** @type {[typeof Avatar, ]} */ ;
|
|
104
100
|
// @ts-ignore
|
|
105
101
|
const __VLS_0 = __VLS_asFunctionalComponent(Avatar, new Avatar({
|
|
@@ -133,17 +129,17 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
|
133
129
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
134
130
|
...{ class: "px-3 py-2 rounded-2xl max-w-xs" },
|
|
135
131
|
...{ class: ({
|
|
136
|
-
'rounded-tl-none': !__VLS_ctx.shouldShowAvatar
|
|
137
|
-
'rounded-bl-none': !__VLS_ctx.isEndMessage
|
|
138
|
-
'rounded-tr-none': !__VLS_ctx.shouldShowAvatar
|
|
139
|
-
'rounded-br-none': !__VLS_ctx.isEndMessage
|
|
132
|
+
'rounded-tl-none': !__VLS_ctx.shouldShowAvatar && !__VLS_ctx.isMyMessage,
|
|
133
|
+
'rounded-bl-none': !__VLS_ctx.isEndMessage && !__VLS_ctx.isMyMessage,
|
|
134
|
+
'rounded-tr-none': !__VLS_ctx.shouldShowAvatar && __VLS_ctx.isMyMessage,
|
|
135
|
+
'rounded-br-none': !__VLS_ctx.isEndMessage && __VLS_ctx.isMyMessage,
|
|
140
136
|
'!text-[#14532D] !bg-[#d4f8d4]': __VLS_ctx.message.message_uuid && !__VLS_ctx.message.is_call,
|
|
141
137
|
'bg-[#D0DFEC] text-[#266699]': __VLS_ctx.isMyMessage,
|
|
142
138
|
'bg-[#E4E4E4D4] text-chat-haze-600 text-left w-max ': !__VLS_ctx.isMyMessage
|
|
143
139
|
}) },
|
|
144
140
|
});
|
|
145
141
|
// @ts-ignore
|
|
146
|
-
[shouldShowAvatar, shouldShowAvatar,
|
|
142
|
+
[shouldShowAvatar, shouldShowAvatar, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, message, message, isEndMessage, isEndMessage,];
|
|
147
143
|
if (__VLS_ctx.message.is_call == 1) {
|
|
148
144
|
// @ts-ignore
|
|
149
145
|
[message,];
|
|
@@ -151,7 +147,7 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
|
151
147
|
...{ class: "flex flex-col gap-2 w-[200px]" },
|
|
152
148
|
});
|
|
153
149
|
__VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
|
|
154
|
-
...{ class: "font-medium
|
|
150
|
+
...{ class: "font-medium" },
|
|
155
151
|
...{ class: ({ 'text-chat-error': __VLS_ctx.message.call_status !== __VLS_ctx.PLIVO_CALL_STATUS.CALL_END }) },
|
|
156
152
|
});
|
|
157
153
|
// @ts-ignore
|
|
@@ -193,20 +189,28 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
|
193
189
|
...{ class: "w-5 h-5" },
|
|
194
190
|
}, ...__VLS_functionalComponentArgsRest(__VLS_8));
|
|
195
191
|
}
|
|
192
|
+
__VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({});
|
|
196
193
|
(__VLS_ctx.getCallDuration(__VLS_ctx.message?.duration ?? 0));
|
|
197
194
|
// @ts-ignore
|
|
198
195
|
[message, getCallDuration,];
|
|
199
|
-
__VLS_asFunctionalElement(__VLS_elements.
|
|
200
|
-
...{
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
__VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
197
|
+
...{ onClick: (...[$event]) => {
|
|
198
|
+
if (!(__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending))
|
|
199
|
+
return;
|
|
200
|
+
if (!(__VLS_ctx.message.is_call == 1))
|
|
201
|
+
return;
|
|
202
|
+
__VLS_ctx.emit('callAgain');
|
|
203
|
+
// @ts-ignore
|
|
204
|
+
[emit,];
|
|
205
|
+
} },
|
|
203
206
|
...{ class: "flex-center h-10 rounded-xl bg-chat-haze-200 font-semibold" },
|
|
204
207
|
});
|
|
205
|
-
__VLS_asFunctionalElement(__VLS_elements.
|
|
208
|
+
__VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({});
|
|
206
209
|
}
|
|
207
210
|
else if (__VLS_ctx.message.message) {
|
|
208
211
|
// @ts-ignore
|
|
209
212
|
[message,];
|
|
213
|
+
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({});
|
|
210
214
|
__VLS_asFunctionalElement(__VLS_elements.div)({
|
|
211
215
|
...{ style: ({ wordBreak: 'break-word' }) },
|
|
212
216
|
});
|
|
@@ -214,13 +218,13 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
|
214
218
|
// @ts-ignore
|
|
215
219
|
[message,];
|
|
216
220
|
}
|
|
217
|
-
else if (__VLS_ctx.message
|
|
221
|
+
else if (__VLS_ctx.message?.attachments?.length) {
|
|
218
222
|
// @ts-ignore
|
|
219
223
|
[message,];
|
|
220
224
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({});
|
|
221
225
|
__VLS_asFunctionalElement(__VLS_elements.img)({
|
|
222
226
|
...{ onLoad: (() => {
|
|
223
|
-
if (__VLS_ctx.
|
|
227
|
+
if (__VLS_ctx.isLastMessage) {
|
|
224
228
|
__VLS_ctx.scrollBottom();
|
|
225
229
|
}
|
|
226
230
|
}) },
|
|
@@ -228,15 +232,25 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
|
228
232
|
alt: "avatar",
|
|
229
233
|
});
|
|
230
234
|
// @ts-ignore
|
|
231
|
-
[
|
|
235
|
+
[message, isLastMessage, scrollBottom,];
|
|
236
|
+
}
|
|
237
|
+
if (__VLS_ctx.isChatFinished) {
|
|
238
|
+
// @ts-ignore
|
|
239
|
+
[isChatFinished,];
|
|
240
|
+
__VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
|
|
241
|
+
...{ class: "text-sm mt-1" },
|
|
242
|
+
});
|
|
243
|
+
(__VLS_ctx.dayjs(__VLS_ctx.message?.created_at).format(__VLS_ctx.DATE_FORMATS.TIME_12_FORMAT));
|
|
244
|
+
// @ts-ignore
|
|
245
|
+
[message, dayjs, DATE_FORMATS,];
|
|
232
246
|
}
|
|
233
247
|
if (__VLS_ctx.isMyMessage) {
|
|
234
248
|
// @ts-ignore
|
|
235
249
|
[isMyMessage,];
|
|
236
|
-
if ((__VLS_ctx.
|
|
250
|
+
if ((__VLS_ctx.isLastMessage && __VLS_ctx.getMessageStateText(__VLS_ctx.message)) ||
|
|
237
251
|
__VLS_ctx.message.state == __VLS_ctx.MessageState.Failed) {
|
|
238
252
|
// @ts-ignore
|
|
239
|
-
[
|
|
253
|
+
[message, message, MessageState, isLastMessage, getMessageStateText,];
|
|
240
254
|
__VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
|
|
241
255
|
...{ class: "text-chat-haze-200 text-xs mt-1" },
|
|
242
256
|
...{ class: ({ '!text-chat-error': __VLS_ctx.message.state == __VLS_ctx.MessageState.Failed }) },
|
|
@@ -302,19 +316,19 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
|
302
316
|
/** @type {__VLS_StyleScopedClasses['h-full']} */ ;
|
|
303
317
|
/** @type {__VLS_StyleScopedClasses['w-5']} */ ;
|
|
304
318
|
/** @type {__VLS_StyleScopedClasses['h-5']} */ ;
|
|
305
|
-
/** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
|
|
306
|
-
/** @type {__VLS_StyleScopedClasses['text-red-600']} */ ;
|
|
307
|
-
/** @type {__VLS_StyleScopedClasses['mt-1']} */ ;
|
|
308
319
|
/** @type {__VLS_StyleScopedClasses['flex-center']} */ ;
|
|
309
320
|
/** @type {__VLS_StyleScopedClasses['h-10']} */ ;
|
|
310
321
|
/** @type {__VLS_StyleScopedClasses['rounded-xl']} */ ;
|
|
311
322
|
/** @type {__VLS_StyleScopedClasses['bg-chat-haze-200']} */ ;
|
|
312
323
|
/** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
|
|
324
|
+
/** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
|
|
325
|
+
/** @type {__VLS_StyleScopedClasses['mt-1']} */ ;
|
|
313
326
|
/** @type {__VLS_StyleScopedClasses['text-chat-haze-200']} */ ;
|
|
314
327
|
/** @type {__VLS_StyleScopedClasses['text-xs']} */ ;
|
|
315
328
|
/** @type {__VLS_StyleScopedClasses['mt-1']} */ ;
|
|
316
329
|
/** @type {__VLS_StyleScopedClasses['!text-chat-error']} */ ;
|
|
317
330
|
const __VLS_export = (await import('vue')).defineComponent({
|
|
331
|
+
__typeEmits: {},
|
|
318
332
|
__typeProps: {},
|
|
319
333
|
props: {},
|
|
320
334
|
});
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
import HomeHeader from '../../../chat/page/home/HomeHeader.vue';
|
|
3
3
|
import NewCustomer from '../../../chat/page/home/NewCustomer.vue';
|
|
4
4
|
import InputChat from '../../../chat/page/home/InputChat.vue';
|
|
5
|
-
import {
|
|
5
|
+
import { getDetailReceiver, getMessage, sendMessage, upLoadImage } from '../../../utils/chat/message';
|
|
6
6
|
import { 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_DETAIL_CHAT
|
|
10
|
-
import { dataProfile } from '../../../utils/chat/auth';
|
|
11
|
-
import dayjs from 'dayjs';
|
|
12
|
-
import { DATE_FORMATS, TIME_ZONE_UTC } from '../../../constant/datetime';
|
|
9
|
+
import { TOPIC_DETAIL_CHAT } from '../../../constant/mqtt';
|
|
13
10
|
import { MessageState } from '../../../constant/message';
|
|
11
|
+
import { publicTopicConversationUpdate } from '../../../utils/chat/conversation';
|
|
14
12
|
const props = withDefaults(defineProps(), {});
|
|
15
13
|
const emit = defineEmits();
|
|
16
14
|
let page = 1;
|
|
@@ -42,8 +40,7 @@ const handleDisconnectMqtt = async () => {
|
|
|
42
40
|
removeHandleMqttMessage('chat-home');
|
|
43
41
|
};
|
|
44
42
|
const mqttMessageHandler = (topic, message) => {
|
|
45
|
-
if ((infoUser.value?.id && message?.sender_id?.toString() == infoUser.value?.id?.toString())
|
|
46
|
-
true) {
|
|
43
|
+
if ((infoUser.value?.id && message?.sender_id?.toString() == infoUser.value?.id?.toString())) {
|
|
47
44
|
const index = listMessage.value.findIndex((item) => item.id === message?.id);
|
|
48
45
|
if (index < 0) {
|
|
49
46
|
listMessage.value.push(message);
|
|
@@ -57,7 +54,7 @@ const mqttMessageHandler = (topic, message) => {
|
|
|
57
54
|
const handleGetMessage = async (option) => {
|
|
58
55
|
try {
|
|
59
56
|
const id = props.receiverId;
|
|
60
|
-
const params = { page: page, receiver_id: props.receiverId };
|
|
57
|
+
const params = { page: option?.resetList ? 1 : page, receiver_id: props.receiverId };
|
|
61
58
|
let res = await getMessage(params);
|
|
62
59
|
res.items = res.items.reverse();
|
|
63
60
|
page = res._meta?.currentPage || 1;
|
|
@@ -89,7 +86,7 @@ const handleScrollTop = async () => {
|
|
|
89
86
|
const handleGetDetailReceiver = async (data) => {
|
|
90
87
|
const id = props.receiverId;
|
|
91
88
|
if (data)
|
|
92
|
-
infoUser.value = data;
|
|
89
|
+
infoUser.value = { ...data, conversation_id: data.id };
|
|
93
90
|
const res = (await getDetailReceiver(props.receiverId)) ?? null;
|
|
94
91
|
if (id == props.receiverId) {
|
|
95
92
|
infoUser.value = res;
|
|
@@ -100,7 +97,8 @@ const getData = async (data) => {
|
|
|
100
97
|
try {
|
|
101
98
|
isLoading.value = true;
|
|
102
99
|
listMessage.value = [];
|
|
103
|
-
|
|
100
|
+
handleGetDetailReceiver(data);
|
|
101
|
+
await Promise.allSettled([handleGetMessage({ resetList: true })]);
|
|
104
102
|
// readMessages(infoUser.value?.conversation_id)
|
|
105
103
|
await nextTick();
|
|
106
104
|
chatMessageRef.value?.scrollBottom();
|
|
@@ -153,7 +151,7 @@ const handleSendMessage = async (data) => {
|
|
|
153
151
|
: []
|
|
154
152
|
});
|
|
155
153
|
updateMessageItem(data.id, { state: MessageState.Sent });
|
|
156
|
-
publicTopicConversationUpdate(
|
|
154
|
+
publicTopicConversationUpdate({ message: data?.message ?? '', isSendImg: !!file_upload?.length, infoUser: infoUser.value });
|
|
157
155
|
}
|
|
158
156
|
catch (error) {
|
|
159
157
|
updateMessageItem(data.id, {
|
|
@@ -174,49 +172,12 @@ const handleUploadImage = async (file) => {
|
|
|
174
172
|
const res = await upLoadImage(formData);
|
|
175
173
|
return res;
|
|
176
174
|
};
|
|
177
|
-
const publicTopicConversationUpdate = async (isSendImg, message) => {
|
|
178
|
-
const res = await getCountUnread({
|
|
179
|
-
conversation_id: infoUser.value?.conversation_id ?? 0,
|
|
180
|
-
receiver_id: Number(infoUser.value?.id)
|
|
181
|
-
});
|
|
182
|
-
const current = dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']);
|
|
183
|
-
const dataMessageForReceiver = {
|
|
184
|
-
id: infoUser.value?.conversation_id ?? 0,
|
|
185
|
-
receiver_id: Number(dataProfile.value?.id ?? 0),
|
|
186
|
-
username: dataProfile.value?.username ?? '',
|
|
187
|
-
customer_phone: dataProfile.value?.phone ?? '',
|
|
188
|
-
avatar: dataProfile.value?.avatar ?? '',
|
|
189
|
-
last_message: isSendImg ? `${infoUser.value?.username} sent images` : message,
|
|
190
|
-
last_message_time: current,
|
|
191
|
-
created_at: current,
|
|
192
|
-
updated_at: current,
|
|
193
|
-
unread_count: (res?.unread_count ?? 0) + 1,
|
|
194
|
-
status: 1,
|
|
195
|
-
color: dataProfile.value?.color ?? ''
|
|
196
|
-
};
|
|
197
|
-
publishMessage(`${TOPIC_HOME[0] + Number(infoUser.value?.id)}`, JSON.stringify(dataMessageForReceiver));
|
|
198
|
-
const dataMessageMyself = {
|
|
199
|
-
id: infoUser.value?.conversation_id ?? 0,
|
|
200
|
-
receiver_id: Number(dataProfile.value?.id ?? 0),
|
|
201
|
-
username: infoUser.value?.username ?? '',
|
|
202
|
-
customer_phone: infoUser.value?.phone ?? '',
|
|
203
|
-
avatar: infoUser.value?.avatar ?? '',
|
|
204
|
-
last_message: isSendImg ? `${infoUser.value?.username} sent images` : message,
|
|
205
|
-
last_message_time: current,
|
|
206
|
-
created_at: current,
|
|
207
|
-
updated_at: current,
|
|
208
|
-
unread_count: 0,
|
|
209
|
-
status: 1,
|
|
210
|
-
color: infoUser.value?.color
|
|
211
|
-
};
|
|
212
|
-
publishMessage(`${TOPIC_HOME[0] + Number(dataProfile.value?.id)}`, JSON.stringify(dataMessageMyself));
|
|
213
|
-
};
|
|
214
175
|
const call = () => {
|
|
215
176
|
if (infoUser.value) {
|
|
216
177
|
emit('call', infoUser.value);
|
|
217
178
|
}
|
|
218
179
|
};
|
|
219
|
-
const __VLS_exposed = { getData, handleGetMessage };
|
|
180
|
+
const __VLS_exposed = { getData, handleGetMessage, infoUser };
|
|
220
181
|
defineExpose(__VLS_exposed);
|
|
221
182
|
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
|
222
183
|
const __VLS_defaults = {};
|
|
@@ -259,6 +220,7 @@ if (__VLS_ctx.listMessage?.length) {
|
|
|
259
220
|
// @ts-ignore
|
|
260
221
|
const __VLS_7 = __VLS_asFunctionalComponent(ChatMessage, new ChatMessage({
|
|
261
222
|
...{ 'onScrollTop': {} },
|
|
223
|
+
...{ 'onCallBack': {} },
|
|
262
224
|
ref: "chatMessageRef",
|
|
263
225
|
data: (__VLS_ctx.infoUser),
|
|
264
226
|
message: (__VLS_ctx.listMessage),
|
|
@@ -268,6 +230,7 @@ if (__VLS_ctx.listMessage?.length) {
|
|
|
268
230
|
}));
|
|
269
231
|
const __VLS_8 = __VLS_7({
|
|
270
232
|
...{ 'onScrollTop': {} },
|
|
233
|
+
...{ 'onCallBack': {} },
|
|
271
234
|
ref: "chatMessageRef",
|
|
272
235
|
data: (__VLS_ctx.infoUser),
|
|
273
236
|
message: (__VLS_ctx.listMessage),
|
|
@@ -279,10 +242,12 @@ if (__VLS_ctx.listMessage?.length) {
|
|
|
279
242
|
let __VLS_11;
|
|
280
243
|
const __VLS_12 = ({ scrollTop: {} },
|
|
281
244
|
{ onScrollTop: (__VLS_ctx.handleScrollTop) });
|
|
245
|
+
const __VLS_13 = ({ callBack: {} },
|
|
246
|
+
{ onCallBack: (__VLS_ctx.call) });
|
|
282
247
|
/** @type {typeof __VLS_ctx.chatMessageRef} */ ;
|
|
283
|
-
var
|
|
248
|
+
var __VLS_14 = {};
|
|
284
249
|
// @ts-ignore
|
|
285
|
-
[infoUser, listMessage, responsive, page, pageCount, handleScrollTop, chatMessageRef,];
|
|
250
|
+
[infoUser, call, listMessage, responsive, page, pageCount, handleScrollTop, chatMessageRef,];
|
|
286
251
|
var __VLS_9;
|
|
287
252
|
}
|
|
288
253
|
else if (!__VLS_ctx.isLoading) {
|
|
@@ -290,14 +255,14 @@ else if (!__VLS_ctx.isLoading) {
|
|
|
290
255
|
[isLoading,];
|
|
291
256
|
/** @type {[typeof NewCustomer, ]} */ ;
|
|
292
257
|
// @ts-ignore
|
|
293
|
-
const
|
|
258
|
+
const __VLS_17 = __VLS_asFunctionalComponent(NewCustomer, new NewCustomer({
|
|
294
259
|
data: (__VLS_ctx.infoUser),
|
|
295
260
|
...{ class: "grow" },
|
|
296
261
|
}));
|
|
297
|
-
const
|
|
262
|
+
const __VLS_18 = __VLS_17({
|
|
298
263
|
data: (__VLS_ctx.infoUser),
|
|
299
264
|
...{ class: "grow" },
|
|
300
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
265
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_17));
|
|
301
266
|
// @ts-ignore
|
|
302
267
|
[infoUser,];
|
|
303
268
|
}
|
|
@@ -308,23 +273,23 @@ else {
|
|
|
308
273
|
}
|
|
309
274
|
/** @type {[typeof InputChat, ]} */ ;
|
|
310
275
|
// @ts-ignore
|
|
311
|
-
const
|
|
276
|
+
const __VLS_21 = __VLS_asFunctionalComponent(InputChat, new InputChat({
|
|
312
277
|
...{ 'onSendMessage': {} },
|
|
313
278
|
data: (__VLS_ctx.infoUser),
|
|
314
279
|
...{ class: "p-6" },
|
|
315
280
|
}));
|
|
316
|
-
const
|
|
281
|
+
const __VLS_22 = __VLS_21({
|
|
317
282
|
...{ 'onSendMessage': {} },
|
|
318
283
|
data: (__VLS_ctx.infoUser),
|
|
319
284
|
...{ class: "p-6" },
|
|
320
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
321
|
-
let __VLS_23;
|
|
285
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_21));
|
|
322
286
|
let __VLS_24;
|
|
323
|
-
|
|
287
|
+
let __VLS_25;
|
|
288
|
+
const __VLS_26 = ({ sendMessage: {} },
|
|
324
289
|
{ onSendMessage: (__VLS_ctx.handleSendMessage) });
|
|
325
290
|
// @ts-ignore
|
|
326
291
|
[infoUser, handleSendMessage,];
|
|
327
|
-
var
|
|
292
|
+
var __VLS_23;
|
|
328
293
|
/** @type {__VLS_StyleScopedClasses['h-full']} */ ;
|
|
329
294
|
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
330
295
|
/** @type {__VLS_StyleScopedClasses['flex-col']} */ ;
|
|
@@ -335,7 +300,7 @@ var __VLS_22;
|
|
|
335
300
|
/** @type {__VLS_StyleScopedClasses['grow']} */ ;
|
|
336
301
|
/** @type {__VLS_StyleScopedClasses['p-6']} */ ;
|
|
337
302
|
// @ts-ignore
|
|
338
|
-
var
|
|
303
|
+
var __VLS_15 = __VLS_14;
|
|
339
304
|
const __VLS_export = (await import('vue')).defineComponent({
|
|
340
305
|
setup: () => (__VLS_exposed),
|
|
341
306
|
__typeEmits: {},
|
|
@@ -79,9 +79,6 @@ __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
|
|
|
79
79
|
(__VLS_ctx.data?.username ?? 'n/a');
|
|
80
80
|
// @ts-ignore
|
|
81
81
|
[data,];
|
|
82
|
-
__VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
|
|
83
|
-
...{ class: "text-sm text-chat-gray-3 truncate" },
|
|
84
|
-
});
|
|
85
82
|
if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() && __VLS_ctx.dataProfile?.user_type == 'tenant') {
|
|
86
83
|
// @ts-ignore
|
|
87
84
|
[dataProfile, data, data, digibotId,];
|
|
@@ -116,9 +113,6 @@ if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() &
|
|
|
116
113
|
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
117
114
|
/** @type {__VLS_StyleScopedClasses['items-center']} */ ;
|
|
118
115
|
/** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
|
|
119
|
-
/** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
|
|
120
|
-
/** @type {__VLS_StyleScopedClasses['text-chat-gray-3']} */ ;
|
|
121
|
-
/** @type {__VLS_StyleScopedClasses['truncate']} */ ;
|
|
122
116
|
/** @type {__VLS_StyleScopedClasses['flex-center']} */ ;
|
|
123
117
|
/** @type {__VLS_StyleScopedClasses['text-[#0051E6]']} */ ;
|
|
124
118
|
/** @type {__VLS_StyleScopedClasses['bg-chat-haze-200']} */ ;
|
|
@@ -42,7 +42,6 @@ const handleSendMessage = async (type) => {
|
|
|
42
42
|
keyword.value = '';
|
|
43
43
|
chatId++;
|
|
44
44
|
const id = props.data?.id.toString() + '-' + chatId;
|
|
45
|
-
console.log(dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']));
|
|
46
45
|
const data = {
|
|
47
46
|
conversation_id: 135,
|
|
48
47
|
created_at: dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']),
|