@phonghq/go-chat 1.0.35 → 1.0.36
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/IconSms.vue.d.ts +2 -0
- package/dist/composable/useError.d.ts +4 -0
- package/dist/composable/usePlivo.d.ts +4 -1
- package/dist/constant/mqtt.d.ts +1 -1
- package/dist/go-chat.es.js +23215 -23193
- package/dist/go-chat.umd.js +14 -13
- package/dist/style.css +1 -1
- package/dist/test/assets/icons/IconSms.vue.js +22 -0
- package/dist/test/chat/App.vue.js +91 -46
- package/dist/test/chat/page/home/ChatList.vue.js +27 -43
- package/dist/test/chat/page/home/ChatMessageItem.vue.js +5 -5
- package/dist/test/chat/page/home/Home.vue.js +3 -1
- package/dist/test/chat/page/home/HomeHeader.vue.js +74 -2
- package/dist/test/chat/page/home/InputChat.vue.js +22 -66
- package/dist/test/components/chat/ScrollEvent/ScrollEvent.vue.js +2 -0
- package/dist/test/components/chat/call/Calling.vue.js +39 -5
- package/dist/test/composable/useError.js +10 -0
- package/dist/test/composable/useListConversations.js +1 -1
- package/dist/test/composable/usePlivo.js +30 -23
- package/dist/test/constant/mqtt.js +3 -2
- package/dist/test/utils/chat/call.js +16 -0
- package/dist/test/utils/chat/conversation.js +3 -3
- package/dist/test/utils/string-helper.js +1 -1
- package/dist/types/chat/auth.d.ts +1 -0
- package/dist/types/message.d.ts +1 -0
- package/dist/utils/chat/auth.d.ts +2 -0
- package/dist/utils/chat/call.d.ts +4 -0
- package/package.json +1 -1
|
@@ -87,9 +87,9 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
|
87
87
|
});
|
|
88
88
|
// @ts-ignore
|
|
89
89
|
[shouldShowAvatar, isMyMessage, isMyMessage,];
|
|
90
|
-
if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
90
|
+
if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending || __VLS_ctx.isMyMessage) {
|
|
91
91
|
// @ts-ignore
|
|
92
|
-
[message, MessageState,];
|
|
92
|
+
[isMyMessage, message, MessageState,];
|
|
93
93
|
if (!__VLS_ctx.isMyMessage) {
|
|
94
94
|
// @ts-ignore
|
|
95
95
|
[isMyMessage,];
|
|
@@ -133,13 +133,13 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
|
133
133
|
'rounded-bl-none': !__VLS_ctx.isEndMessage && !__VLS_ctx.isMyMessage,
|
|
134
134
|
'rounded-tr-none': !__VLS_ctx.shouldShowAvatar && __VLS_ctx.isMyMessage,
|
|
135
135
|
'rounded-br-none': !__VLS_ctx.isEndMessage && __VLS_ctx.isMyMessage,
|
|
136
|
-
'!text-[#14532D] !bg-[#d4f8d4]': __VLS_ctx.message.message_uuid && !__VLS_ctx.message.is_call,
|
|
136
|
+
'!text-[#14532D] !bg-[#d4f8d4]': (__VLS_ctx.message.message_uuid && !__VLS_ctx.message.is_call) || __VLS_ctx.message.is_sms,
|
|
137
137
|
'bg-[#D0DFEC] text-[#266699]': __VLS_ctx.isMyMessage,
|
|
138
138
|
'bg-[#E4E4E4D4] text-chat-haze-600 w-max ': !__VLS_ctx.isMyMessage
|
|
139
139
|
}) },
|
|
140
140
|
});
|
|
141
141
|
// @ts-ignore
|
|
142
|
-
[shouldShowAvatar, shouldShowAvatar, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, message, message, isEndMessage, isEndMessage,];
|
|
142
|
+
[shouldShowAvatar, shouldShowAvatar, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, message, message, message, isEndMessage, isEndMessage,];
|
|
143
143
|
if (__VLS_ctx.message.is_call == 1) {
|
|
144
144
|
// @ts-ignore
|
|
145
145
|
[message,];
|
|
@@ -195,7 +195,7 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
|
|
|
195
195
|
[message, getCallDuration,];
|
|
196
196
|
__VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
197
197
|
...{ onClick: (...[$event]) => {
|
|
198
|
-
if (!(__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending))
|
|
198
|
+
if (!(__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending || __VLS_ctx.isMyMessage))
|
|
199
199
|
return;
|
|
200
200
|
if (!(__VLS_ctx.message.is_call == 1))
|
|
201
201
|
return;
|
|
@@ -35,6 +35,7 @@ const handleConnectMqtt = async () => {
|
|
|
35
35
|
// console.log(topic)
|
|
36
36
|
// console.log(topic_plivo_chat)
|
|
37
37
|
addHandleMqttMessage('chat-home', topic, mqttMessageHandler);
|
|
38
|
+
addHandleMqttMessage('chat-home-1', topic_plivo_chat, mqttMessageHandler);
|
|
38
39
|
}
|
|
39
40
|
catch (error) {
|
|
40
41
|
console.error(error);
|
|
@@ -44,9 +45,9 @@ const handleDisconnectMqtt = async () => {
|
|
|
44
45
|
unsubscribeFromTopic(topic);
|
|
45
46
|
unsubscribeFromTopic(topic_plivo_chat);
|
|
46
47
|
removeHandleMqttMessage('chat-home');
|
|
48
|
+
removeHandleMqttMessage('chat-home-1');
|
|
47
49
|
};
|
|
48
50
|
const mqttMessageHandler = (topic, message) => {
|
|
49
|
-
console.log(message);
|
|
50
51
|
if ((infoUser.value?.id && message?.sender_id?.toString() == infoUser.value?.id?.toString())) {
|
|
51
52
|
const index = listMessage.value.findIndex((item) => item.id === message?.id);
|
|
52
53
|
if (index < 0) {
|
|
@@ -132,6 +133,7 @@ const handleSendMessage = async (data) => {
|
|
|
132
133
|
try {
|
|
133
134
|
// listMessage.value.push({ ...data, state: MessageState.Sending })
|
|
134
135
|
listMessage.value.unshift({ ...data, state: MessageState.Sending });
|
|
136
|
+
await nextTick();
|
|
135
137
|
publishMessage(topic, {
|
|
136
138
|
...data,
|
|
137
139
|
state: MessageState.Sending
|
|
@@ -7,8 +7,14 @@ import { user } from '../../../utils/chat/user';
|
|
|
7
7
|
import { dataProfile } from '../../../utils/chat/auth';
|
|
8
8
|
import { digibotId } from '../../../composable/useDigibot';
|
|
9
9
|
import IconArrowLeft from '../../../assets/icons/IconArrowLeft.vue';
|
|
10
|
+
import IconSms from '../../../assets/icons/IconSms.vue';
|
|
11
|
+
import { activePlivoMode } from '../../..//utils/chat/message';
|
|
12
|
+
import { ref } from 'vue';
|
|
13
|
+
import ButtonBase from '../../../components/common/button/ButtonBase.vue';
|
|
10
14
|
const props = withDefaults(defineProps(), {});
|
|
11
15
|
const emit = defineEmits();
|
|
16
|
+
const activePlivoSms = ref(dataProfile.value?.is_sms_active == 1);
|
|
17
|
+
const loading = ref(false);
|
|
12
18
|
const goToViewUser = () => {
|
|
13
19
|
if (props.data?.id == digibotId.toString())
|
|
14
20
|
return;
|
|
@@ -17,6 +23,21 @@ const goToViewUser = () => {
|
|
|
17
23
|
routerPush(PAGE.CUSTOMER_DETAIL);
|
|
18
24
|
}
|
|
19
25
|
};
|
|
26
|
+
const handleActivePlivoSmsChange = async (is_active) => {
|
|
27
|
+
return;
|
|
28
|
+
try {
|
|
29
|
+
loading.value = true;
|
|
30
|
+
await activePlivoMode({ id: dataProfile.value?.id, is_sms: is_active ? 1 : 0 });
|
|
31
|
+
if (dataProfile.value != null)
|
|
32
|
+
dataProfile.value.is_sms_active = (is_active ? 1 : 0);
|
|
33
|
+
activePlivoSms.value = is_active;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
activePlivoSms.value = !is_active;
|
|
37
|
+
console.log(e);
|
|
38
|
+
}
|
|
39
|
+
loading.value = false;
|
|
40
|
+
};
|
|
20
41
|
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
|
21
42
|
const __VLS_defaults = {};
|
|
22
43
|
const __VLS_ctx = {
|
|
@@ -102,6 +123,46 @@ __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
|
|
|
102
123
|
(__VLS_ctx.data?.username ?? 'n/a');
|
|
103
124
|
// @ts-ignore
|
|
104
125
|
[data,];
|
|
126
|
+
if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() && __VLS_ctx.dataProfile?.user_type == 'tenant') {
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
[dataProfile, data, data, digibotId,];
|
|
129
|
+
/** @type {[typeof ButtonBase, typeof ButtonBase, ]} */ ;
|
|
130
|
+
// @ts-ignore
|
|
131
|
+
const __VLS_11 = __VLS_asFunctionalComponent(ButtonBase, new ButtonBase({
|
|
132
|
+
...{ 'onClick': {} },
|
|
133
|
+
type: (__VLS_ctx.activePlivoSms ? 'success' : 'danger'),
|
|
134
|
+
loading: (__VLS_ctx.loading),
|
|
135
|
+
...{ class: "shrink-0 px-1 flex-center gap-2 text-white font-semibold w-9 md:w-[140px] h-9" },
|
|
136
|
+
}));
|
|
137
|
+
const __VLS_12 = __VLS_11({
|
|
138
|
+
...{ 'onClick': {} },
|
|
139
|
+
type: (__VLS_ctx.activePlivoSms ? 'success' : 'danger'),
|
|
140
|
+
loading: (__VLS_ctx.loading),
|
|
141
|
+
...{ class: "shrink-0 px-1 flex-center gap-2 text-white font-semibold w-9 md:w-[140px] h-9" },
|
|
142
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_11));
|
|
143
|
+
let __VLS_14;
|
|
144
|
+
let __VLS_15;
|
|
145
|
+
const __VLS_16 = ({ click: {} },
|
|
146
|
+
{ onClick: (...[$event]) => {
|
|
147
|
+
if (!(__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() && __VLS_ctx.dataProfile?.user_type == 'tenant'))
|
|
148
|
+
return;
|
|
149
|
+
__VLS_ctx.handleActivePlivoSmsChange(!__VLS_ctx.activePlivoSms);
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
[activePlivoSms, activePlivoSms, loading, handleActivePlivoSmsChange,];
|
|
152
|
+
} });
|
|
153
|
+
const { default: __VLS_17 } = __VLS_13.slots;
|
|
154
|
+
/** @type {[typeof IconSms, ]} */ ;
|
|
155
|
+
// @ts-ignore
|
|
156
|
+
const __VLS_18 = __VLS_asFunctionalComponent(IconSms, new IconSms({}));
|
|
157
|
+
const __VLS_19 = __VLS_18({}, ...__VLS_functionalComponentArgsRest(__VLS_18));
|
|
158
|
+
__VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
|
|
159
|
+
...{ class: "hidden md:block" },
|
|
160
|
+
});
|
|
161
|
+
(__VLS_ctx.activePlivoSms ? 'ON' : 'OFF');
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
[activePlivoSms,];
|
|
164
|
+
var __VLS_13;
|
|
165
|
+
}
|
|
105
166
|
if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() && __VLS_ctx.dataProfile?.user_type == 'tenant') {
|
|
106
167
|
// @ts-ignore
|
|
107
168
|
[dataProfile, data, data, digibotId,];
|
|
@@ -117,8 +178,8 @@ if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() &
|
|
|
117
178
|
});
|
|
118
179
|
/** @type {[typeof IconPhone, ]} */ ;
|
|
119
180
|
// @ts-ignore
|
|
120
|
-
const
|
|
121
|
-
const
|
|
181
|
+
const __VLS_22 = __VLS_asFunctionalComponent(IconPhone, new IconPhone({}));
|
|
182
|
+
const __VLS_23 = __VLS_22({}, ...__VLS_functionalComponentArgsRest(__VLS_22));
|
|
122
183
|
}
|
|
123
184
|
/** @type {__VLS_StyleScopedClasses['px-8']} */ ;
|
|
124
185
|
/** @type {__VLS_StyleScopedClasses['pb-4']} */ ;
|
|
@@ -147,6 +208,17 @@ if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() &
|
|
|
147
208
|
/** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
|
|
148
209
|
/** @type {__VLS_StyleScopedClasses['truncate']} */ ;
|
|
149
210
|
/** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
|
|
211
|
+
/** @type {__VLS_StyleScopedClasses['px-1']} */ ;
|
|
212
|
+
/** @type {__VLS_StyleScopedClasses['flex-center']} */ ;
|
|
213
|
+
/** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
|
|
214
|
+
/** @type {__VLS_StyleScopedClasses['text-white']} */ ;
|
|
215
|
+
/** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
|
|
216
|
+
/** @type {__VLS_StyleScopedClasses['w-9']} */ ;
|
|
217
|
+
/** @type {__VLS_StyleScopedClasses['md:w-[140px]']} */ ;
|
|
218
|
+
/** @type {__VLS_StyleScopedClasses['h-9']} */ ;
|
|
219
|
+
/** @type {__VLS_StyleScopedClasses['hidden']} */ ;
|
|
220
|
+
/** @type {__VLS_StyleScopedClasses['md:block']} */ ;
|
|
221
|
+
/** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
|
|
150
222
|
/** @type {__VLS_StyleScopedClasses['flex-center']} */ ;
|
|
151
223
|
/** @type {__VLS_StyleScopedClasses['text-[#0051E6]']} */ ;
|
|
152
224
|
/** @type {__VLS_StyleScopedClasses['bg-chat-haze-200']} */ ;
|
|
@@ -8,9 +8,7 @@ import { DATE_FORMATS, TIME_ZONE_UTC } from '../../../constant/datetime';
|
|
|
8
8
|
import { dataProfile } from '../../../utils/chat/auth';
|
|
9
9
|
import { computed, ref } from 'vue';
|
|
10
10
|
import PopoverBase from '../../../components/chat/common/popover/PopoverBase.vue';
|
|
11
|
-
import SwitchBase from '../../../components/chat/common/switch/SwitchBase.vue';
|
|
12
11
|
import { activePlivoMode } from '../../../utils/chat/message';
|
|
13
|
-
import BaseSpin from '../../../components/chat/common/spin/BaseSpin.vue';
|
|
14
12
|
const props = withDefaults(defineProps(), {});
|
|
15
13
|
const emit = defineEmits();
|
|
16
14
|
const ChatModeOptions = [
|
|
@@ -49,14 +47,15 @@ const handleSendMessage = async (type) => {
|
|
|
49
47
|
chatId++;
|
|
50
48
|
const id = props.data?.id.toString() + '-' + chatId;
|
|
51
49
|
const data = {
|
|
52
|
-
conversation_id:
|
|
50
|
+
conversation_id: props.data?.conversation_id,
|
|
53
51
|
created_at: dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']),
|
|
54
52
|
id,
|
|
55
53
|
message: messageContent,
|
|
56
54
|
receiver_id: props.data?.id || 0,
|
|
57
55
|
sender_id: dataProfile.value?.id,
|
|
58
56
|
status: 'read',
|
|
59
|
-
attachments: attachments
|
|
57
|
+
attachments: attachments,
|
|
58
|
+
is_sms: dataProfile.value?.is_sms_active,
|
|
60
59
|
};
|
|
61
60
|
emit('sendMessage', data);
|
|
62
61
|
};
|
|
@@ -126,46 +125,6 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
|
126
125
|
...{ class: "z-10" },
|
|
127
126
|
...{ style: {} },
|
|
128
127
|
});
|
|
129
|
-
if (__VLS_ctx.dataProfile?.user_type == 'tenant') {
|
|
130
|
-
// @ts-ignore
|
|
131
|
-
[dataProfile,];
|
|
132
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
133
|
-
...{ class: "flex gap-2 mb-2" },
|
|
134
|
-
});
|
|
135
|
-
/** @type {[typeof SwitchBase, ]} */ ;
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
const __VLS_0 = __VLS_asFunctionalComponent(SwitchBase, new SwitchBase({
|
|
138
|
-
...{ 'onChange': {} },
|
|
139
|
-
modelValue: (__VLS_ctx.activePlivoSms),
|
|
140
|
-
label: "Active sms",
|
|
141
|
-
}));
|
|
142
|
-
const __VLS_1 = __VLS_0({
|
|
143
|
-
...{ 'onChange': {} },
|
|
144
|
-
modelValue: (__VLS_ctx.activePlivoSms),
|
|
145
|
-
label: "Active sms",
|
|
146
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_0));
|
|
147
|
-
let __VLS_3;
|
|
148
|
-
let __VLS_4;
|
|
149
|
-
const __VLS_5 = ({ change: {} },
|
|
150
|
-
{ onChange: (__VLS_ctx.handleActivePlivoSmsChange) });
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
[activePlivoSms, handleActivePlivoSmsChange,];
|
|
153
|
-
var __VLS_2;
|
|
154
|
-
if (__VLS_ctx.loading) {
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
[loading,];
|
|
157
|
-
/** @type {[typeof BaseSpin, ]} */ ;
|
|
158
|
-
// @ts-ignore
|
|
159
|
-
const __VLS_7 = __VLS_asFunctionalComponent(BaseSpin, new BaseSpin({
|
|
160
|
-
size: (24),
|
|
161
|
-
border: (3),
|
|
162
|
-
}));
|
|
163
|
-
const __VLS_8 = __VLS_7({
|
|
164
|
-
size: (24),
|
|
165
|
-
border: (3),
|
|
166
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_7));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
128
|
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
170
129
|
...{ class: "flex gap-2 items-end h-max" },
|
|
171
130
|
});
|
|
@@ -202,17 +161,17 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
|
202
161
|
});
|
|
203
162
|
/** @type {[typeof PopoverBase, typeof PopoverBase, ]} */ ;
|
|
204
163
|
// @ts-ignore
|
|
205
|
-
const
|
|
164
|
+
const __VLS_0 = __VLS_asFunctionalComponent(PopoverBase, new PopoverBase({
|
|
206
165
|
open: (__VLS_ctx.emojiOpen),
|
|
207
166
|
align: "end",
|
|
208
167
|
side: "top",
|
|
209
168
|
}));
|
|
210
|
-
const
|
|
169
|
+
const __VLS_1 = __VLS_0({
|
|
211
170
|
open: (__VLS_ctx.emojiOpen),
|
|
212
171
|
align: "end",
|
|
213
172
|
side: "top",
|
|
214
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
215
|
-
const { default:
|
|
173
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_0));
|
|
174
|
+
const { default: __VLS_3 } = __VLS_2.slots;
|
|
216
175
|
// @ts-ignore
|
|
217
176
|
[emojiOpen,];
|
|
218
177
|
__VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
@@ -224,35 +183,35 @@ __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
|
224
183
|
...{ class: "h-11 w-10" },
|
|
225
184
|
});
|
|
226
185
|
{
|
|
227
|
-
const { content:
|
|
228
|
-
const
|
|
186
|
+
const { content: __VLS_4 } = __VLS_2.slots;
|
|
187
|
+
const __VLS_5 = {}.EmojiPicker;
|
|
229
188
|
/** @type {[typeof __VLS_components.EmojiPicker, typeof __VLS_components.emojiPicker, ]} */ ;
|
|
230
189
|
// @ts-ignore
|
|
231
190
|
EmojiPicker;
|
|
232
191
|
// @ts-ignore
|
|
233
|
-
const
|
|
192
|
+
const __VLS_6 = __VLS_asFunctionalComponent(__VLS_5, new __VLS_5({
|
|
234
193
|
...{ 'onSelect': {} },
|
|
235
194
|
...{ class: "!w-[300px]" },
|
|
236
195
|
native: (true),
|
|
237
196
|
offset: (2),
|
|
238
197
|
hideSearch: true,
|
|
239
198
|
}));
|
|
240
|
-
const
|
|
199
|
+
const __VLS_7 = __VLS_6({
|
|
241
200
|
...{ 'onSelect': {} },
|
|
242
201
|
...{ class: "!w-[300px]" },
|
|
243
202
|
native: (true),
|
|
244
203
|
offset: (2),
|
|
245
204
|
hideSearch: true,
|
|
246
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
247
|
-
let
|
|
248
|
-
let
|
|
249
|
-
const
|
|
205
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_6));
|
|
206
|
+
let __VLS_9;
|
|
207
|
+
let __VLS_10;
|
|
208
|
+
const __VLS_11 = ({ select: {} },
|
|
250
209
|
{ onSelect: (__VLS_ctx.onSelectEmoji) });
|
|
251
210
|
// @ts-ignore
|
|
252
211
|
[onSelectEmoji,];
|
|
253
|
-
var
|
|
212
|
+
var __VLS_8;
|
|
254
213
|
}
|
|
255
|
-
var
|
|
214
|
+
var __VLS_2;
|
|
256
215
|
__VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
257
216
|
...{ onClick: (...[$event]) => {
|
|
258
217
|
__VLS_ctx.handleSendMessage('message');
|
|
@@ -263,8 +222,8 @@ __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
|
|
|
263
222
|
});
|
|
264
223
|
/** @type {[typeof IconPlan, ]} */ ;
|
|
265
224
|
// @ts-ignore
|
|
266
|
-
const
|
|
267
|
-
const
|
|
225
|
+
const __VLS_13 = __VLS_asFunctionalComponent(IconPlan, new IconPlan({}));
|
|
226
|
+
const __VLS_14 = __VLS_13({}, ...__VLS_functionalComponentArgsRest(__VLS_13));
|
|
268
227
|
__VLS_asFunctionalElement(__VLS_elements.label, __VLS_elements.label)({
|
|
269
228
|
...{ class: "shrink-0 cursor-pointer relative -translate-y-1" },
|
|
270
229
|
});
|
|
@@ -283,18 +242,15 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
|
283
242
|
});
|
|
284
243
|
/** @type {[typeof IconPlus, ]} */ ;
|
|
285
244
|
// @ts-ignore
|
|
286
|
-
const
|
|
245
|
+
const __VLS_17 = __VLS_asFunctionalComponent(IconPlus, new IconPlus({
|
|
287
246
|
...{ class: "text-white" },
|
|
288
247
|
}));
|
|
289
|
-
const
|
|
248
|
+
const __VLS_18 = __VLS_17({
|
|
290
249
|
...{ class: "text-white" },
|
|
291
|
-
}, ...__VLS_functionalComponentArgsRest(
|
|
250
|
+
}, ...__VLS_functionalComponentArgsRest(__VLS_17));
|
|
292
251
|
/** @type {__VLS_StyleScopedClasses['z-10']} */ ;
|
|
293
252
|
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
294
253
|
/** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
|
|
295
|
-
/** @type {__VLS_StyleScopedClasses['mb-2']} */ ;
|
|
296
|
-
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
297
|
-
/** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
|
|
298
254
|
/** @type {__VLS_StyleScopedClasses['items-end']} */ ;
|
|
299
255
|
/** @type {__VLS_StyleScopedClasses['h-max']} */ ;
|
|
300
256
|
/** @type {__VLS_StyleScopedClasses['relative']} */ ;
|
|
@@ -107,6 +107,8 @@ const hideLoading = () => {
|
|
|
107
107
|
loadingTop.value = false;
|
|
108
108
|
};
|
|
109
109
|
const handleScroll = (event, el) => {
|
|
110
|
+
if (props.disabled)
|
|
111
|
+
return;
|
|
110
112
|
const scrollTop = el.scrollTop;
|
|
111
113
|
const scrollHeight = el.scrollHeight;
|
|
112
114
|
const clientHeight = el.clientHeight;
|
|
@@ -12,6 +12,7 @@ import IconClose from '../../../assets/icons/call/IconClose.vue';
|
|
|
12
12
|
import { usePlivo } from '../../../composable/usePlivo';
|
|
13
13
|
import { PLIVO_CALL_STATUS } from '../../../types/chat/call';
|
|
14
14
|
import IconMic from '../../../assets/icons/call/IconMic.vue';
|
|
15
|
+
import { useError } from '../../../composable/useError';
|
|
15
16
|
const props = withDefaults(defineProps(), {});
|
|
16
17
|
const emit = defineEmits();
|
|
17
18
|
// const {
|
|
@@ -49,6 +50,7 @@ const handlePlivoCallBack = (status, data) => {
|
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
52
|
const { plivoLogin, plivoCallAnswer, plivoCall, plivoEndCall, plivoCallSwishMute } = usePlivo(handlePlivoCallBack);
|
|
53
|
+
const { showError } = useError();
|
|
52
54
|
const STATUS_LABEL = computed(() => {
|
|
53
55
|
return {
|
|
54
56
|
[PLIVO_CALL_STATUS.CONNECTING]: 'Connecting...',
|
|
@@ -76,13 +78,20 @@ const userRemoter = ref(null);
|
|
|
76
78
|
const isMute = ref(false);
|
|
77
79
|
let timer = null;
|
|
78
80
|
let timeOut = null;
|
|
81
|
+
let refreshTokenTimeOut = null;
|
|
82
|
+
let refreshTokenCount = null;
|
|
79
83
|
let callType = 'call';
|
|
80
84
|
let uuidEnd = '';
|
|
81
85
|
onMounted(async () => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
try {
|
|
87
|
+
if (dataProfile.value?.tenant_phone) {
|
|
88
|
+
const token = await getPlivoAccessToken();
|
|
89
|
+
await plivoLogin({ token });
|
|
90
|
+
setTimeout(refreshToken, 1000);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
showError('We’re having trouble connecting the call. Please try again in a moment');
|
|
86
95
|
}
|
|
87
96
|
});
|
|
88
97
|
onUnmounted(() => {
|
|
@@ -121,6 +130,31 @@ function endCall(option) {
|
|
|
121
130
|
emit('endCall', userRemoter.value, callType);
|
|
122
131
|
callType = '';
|
|
123
132
|
}
|
|
133
|
+
const refreshToken = async () => {
|
|
134
|
+
try {
|
|
135
|
+
console.log('refreshToken: ');
|
|
136
|
+
if (refreshTokenTimeOut) {
|
|
137
|
+
clearTimeout(refreshTokenTimeOut);
|
|
138
|
+
refreshTokenTimeOut = null;
|
|
139
|
+
}
|
|
140
|
+
const token = await getPlivoAccessToken();
|
|
141
|
+
await plivoLogin({ token, isRefresh: true });
|
|
142
|
+
setTimeout(() => refreshToken(), 15 * 60 * 1000);
|
|
143
|
+
refreshTokenCount = 0;
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
console.log(e);
|
|
147
|
+
refreshTokenCount = refreshTokenCount + 1;
|
|
148
|
+
console.log(refreshTokenCount);
|
|
149
|
+
if (refreshTokenCount < 3) {
|
|
150
|
+
setTimeout(() => refreshToken(), 2 * 60 * 1000);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
showError('We’re having trouble connecting the call. Please try again in a moment');
|
|
154
|
+
}
|
|
155
|
+
console.log(e);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
124
158
|
const open = () => {
|
|
125
159
|
drawerVisible.value = true;
|
|
126
160
|
disable.value = true;
|
|
@@ -159,7 +193,7 @@ const answer = async () => {
|
|
|
159
193
|
const getUserOffer = async (phone) => {
|
|
160
194
|
let res = null;
|
|
161
195
|
try {
|
|
162
|
-
userRemoter.value =
|
|
196
|
+
userRemoter.value = { phone, username: '' };
|
|
163
197
|
let data = {
|
|
164
198
|
phone: formatPhone10number(phone, '1'),
|
|
165
199
|
client_id: dataProfile.value?.tenant_id ?? ''
|
|
@@ -51,7 +51,7 @@ export const useListConversations = (is_unknown) => {
|
|
|
51
51
|
if ((data.is_unknown ?? 0) != is_unknown)
|
|
52
52
|
return;
|
|
53
53
|
getDataMqtt();
|
|
54
|
-
if (topic === TOPIC_HOME[0] + dataProfile.value?.id) {
|
|
54
|
+
if (topic === TOPIC_HOME[0] + dataProfile.value?.id || topic === TOPIC_HOME[3] + dataProfile.value?.id) {
|
|
55
55
|
const index = listConversations.value.findIndex((item) => item.id === data.id);
|
|
56
56
|
const hasChatBox = listConversations.value.findIndex((item) => item.id === digibotId);
|
|
57
57
|
if (index != -1) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { PLIVO_CALL_STATUS } from '../types/chat/call';
|
|
2
|
+
import { createSipAccount } from '../utils/chat/call';
|
|
3
|
+
import { dataProfile } from '../utils/chat/auth';
|
|
2
4
|
export function usePlivo(callback) {
|
|
3
5
|
var options = {
|
|
4
6
|
debug: 'ALL',
|
|
@@ -12,36 +14,41 @@ export function usePlivo(callback) {
|
|
|
12
14
|
let CallUuid = '';
|
|
13
15
|
let custom_resolve = null;
|
|
14
16
|
let custom_reject = null;
|
|
15
|
-
const plivoLogin = async (
|
|
17
|
+
const plivoLogin = async (data) => {
|
|
16
18
|
// token =
|
|
17
19
|
// 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6InBsaXZvO3Y9MSJ9.eyJqdGkiOiJ0ZXN0MSIsImlzcyI6IlNBTjJZMFpERTRNSkFUTVpZNU5DIiwic3ViIjoid2ViY2FsbDAwMzA3OTY3MzQ1NDg5MTgyNyIsIm5iZiI6MTc2MzY5MzUyNSwiZXhwIjoxNzYzNzc5OTI1LCJncmFudHMiOnsidm9pY2UiOnsiaW5jb21pbmdfYWxsb3ciOnRydWUsIm91dGdvaW5nX2FsbG93Ijp0cnVlfX19.9p4O_xTb4kNhKyDVfK3EemSKBQiHtbKNUZ5iwnSdX1I'
|
|
18
20
|
try {
|
|
19
|
-
if (!plivoBrowserSdk)
|
|
21
|
+
if (!plivoBrowserSdk) {
|
|
20
22
|
plivoBrowserSdk = new window.Plivo(options);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
plivoBrowserSdk?.client?.on?.('onCallAnswered', (callInfo) => {
|
|
24
|
+
handleCallAnswered(callInfo);
|
|
25
|
+
});
|
|
26
|
+
plivoBrowserSdk?.client?.on?.('onCallTerminated', (hangupInfo, callInfo) => handleCallTerminated(hangupInfo, callInfo));
|
|
27
|
+
plivoBrowserSdk.client.on('onCallFailed', (data, callInfo) => {
|
|
28
|
+
handleCallFailed(data, callInfo);
|
|
29
|
+
});
|
|
30
|
+
plivoBrowserSdk.client.on('onIncomingCallCanceled', (callInfo) => {
|
|
31
|
+
handleIncomingCallCanceled(callInfo);
|
|
32
|
+
});
|
|
33
|
+
// plivoBrowserSdk.client.on('onCalling', (data: any) => console.log('onCallFailed', data))
|
|
34
|
+
plivoBrowserSdk?.client?.on?.('onIncomingCall', (callerID, extraHeaders, callInfo) => {
|
|
35
|
+
handleIncomingCall(callInfo);
|
|
36
|
+
});
|
|
37
|
+
plivoBrowserSdk.client.on('onCallRemoteRinging', (data) => handleCallRemoteRinging(data));
|
|
38
|
+
plivoBrowserSdk.client.on('onMediaPermission', (e) => handleMediaPermission(e));
|
|
39
|
+
plivoBrowserSdk?.client?.on?.('onLoginFailed', (e) => handleLoginFailed(e));
|
|
40
|
+
}
|
|
41
|
+
if (!data.isRefresh) {
|
|
42
|
+
const payload = JSON.parse(atob(data.token.split('.')[1]));
|
|
43
|
+
await createSipAccount({
|
|
44
|
+
sip_username: `${payload.sub}_${payload.iss}`,
|
|
45
|
+
did_number: dataProfile.value?.tenant_phone ?? ''
|
|
46
|
+
});
|
|
47
|
+
}
|
|
41
48
|
// await plivoBrowserSdk?.client?.tokenLogin(payload.sub ?? '', token)
|
|
42
49
|
// await plivoBrowserSdk?.client?.login('webcall003079673454891827', '123456abcA!')
|
|
43
50
|
// await plivoBrowserSdk?.client?.login(payload.sub , null, token)
|
|
44
|
-
await plivoBrowserSdk?.client?.loginWithAccessToken(token);
|
|
51
|
+
await plivoBrowserSdk?.client?.loginWithAccessToken(data.token);
|
|
45
52
|
// await plivoBrowserSdk?.client?.on?.(payload)
|
|
46
53
|
// console.log('Registered with token')
|
|
47
54
|
}
|
|
@@ -3,9 +3,10 @@ export const TOPIC_DETAIL_CALL = 'call/message/';
|
|
|
3
3
|
export const TOPIC_HOME = [
|
|
4
4
|
'chat/conversation/update/',
|
|
5
5
|
'chat/conversation/read_message/',
|
|
6
|
-
'chat/conversation/update_list/'
|
|
6
|
+
'chat/conversation/update_list/',
|
|
7
|
+
'chat/conversation/update_list/sms-inbound'
|
|
7
8
|
];
|
|
8
|
-
export const TOPIC_PLIVO_SMS = 'sms-
|
|
9
|
+
export const TOPIC_PLIVO_SMS = 'sms-inbound/';
|
|
9
10
|
export const TOPIC_STATUS_USER = 'user/status/';
|
|
10
11
|
// export CALL_STATE = {
|
|
11
12
|
// Offer: 'offer',
|
|
@@ -137,3 +137,19 @@ export const getPlivoAccessToken = async () => {
|
|
|
137
137
|
const result = await response.json();
|
|
138
138
|
return result?.accessToken;
|
|
139
139
|
};
|
|
140
|
+
export const createSipAccount = async (data) => {
|
|
141
|
+
const url = BARE_WEBSOCKET_URL + '/ws/create-sip-account';
|
|
142
|
+
const response = await fetch(url, {
|
|
143
|
+
method: 'POST',
|
|
144
|
+
body: JSON.stringify(data),
|
|
145
|
+
headers: {
|
|
146
|
+
['Content-Type']: 'application/json'
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
if (!response.ok) {
|
|
150
|
+
throw new Error(`Response status: ${response.status}`);
|
|
151
|
+
}
|
|
152
|
+
const result = await response.json();
|
|
153
|
+
console.log(result);
|
|
154
|
+
return result;
|
|
155
|
+
};
|
|
@@ -30,7 +30,7 @@ export const publicTopicConversationUpdate = async (data) => {
|
|
|
30
30
|
const current = dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']);
|
|
31
31
|
const dataMessageForReceiver = {
|
|
32
32
|
id: data.infoUser?.conversation_id ?? 0,
|
|
33
|
-
receiver_id: Number(
|
|
33
|
+
receiver_id: Number(data.infoUser?.id ?? 0),
|
|
34
34
|
username: dataProfile.value?.username ?? '',
|
|
35
35
|
phone: dataProfile.value?.phone ?? '',
|
|
36
36
|
avatar: dataProfile.value?.avatar ?? '',
|
|
@@ -42,12 +42,12 @@ export const publicTopicConversationUpdate = async (data) => {
|
|
|
42
42
|
status: 1,
|
|
43
43
|
color: dataProfile.value?.color ?? '',
|
|
44
44
|
is_call: dataProfile.value?.color ?? '',
|
|
45
|
-
is_unknown: 0
|
|
45
|
+
is_unknown: 0,
|
|
46
46
|
};
|
|
47
47
|
publishMessage(`${TOPIC_HOME[0] + Number(data.infoUser?.id)}`, JSON.stringify(dataMessageForReceiver));
|
|
48
48
|
const dataMessageMyself = {
|
|
49
49
|
id: data.infoUser?.conversation_id ?? 0,
|
|
50
|
-
receiver_id: Number(
|
|
50
|
+
receiver_id: Number(data.infoUser?.id ?? 0),
|
|
51
51
|
username: data.infoUser?.username ?? '',
|
|
52
52
|
phone: data.infoUser?.phone ?? '',
|
|
53
53
|
avatar: data.infoUser?.avatar ?? '',
|
|
@@ -4,7 +4,7 @@ export const phoneNumberFormat = (phone, halfShowType = 1) => {
|
|
|
4
4
|
number = number.substring(number.length - 10);
|
|
5
5
|
}
|
|
6
6
|
if (number.length == 10) {
|
|
7
|
-
if (
|
|
7
|
+
if (false) {
|
|
8
8
|
if (halfShowType == 4) {
|
|
9
9
|
number = (number || '').replace(/(\d{3})(\d{3})(\d{4})/, "*** $3");
|
|
10
10
|
}
|
package/dist/types/message.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare const dataProfile: import("vue").Ref<{
|
|
|
20
20
|
user_type: "customer" | "tenant";
|
|
21
21
|
has_business_tenant_phone?: boolean | undefined;
|
|
22
22
|
color: string;
|
|
23
|
+
is_sms_active: number;
|
|
23
24
|
} | null, IResProfile | {
|
|
24
25
|
id: number;
|
|
25
26
|
username: string;
|
|
@@ -31,6 +32,7 @@ export declare const dataProfile: import("vue").Ref<{
|
|
|
31
32
|
user_type: "customer" | "tenant";
|
|
32
33
|
has_business_tenant_phone?: boolean | undefined;
|
|
33
34
|
color: string;
|
|
35
|
+
is_sms_active: number;
|
|
34
36
|
} | null>;
|
|
35
37
|
export declare const dataLoginLink: import("vue").Ref<{
|
|
36
38
|
token: string;
|
|
@@ -9,3 +9,7 @@ export declare const plivoCall: (user: IResUser) => Promise<any>;
|
|
|
9
9
|
export declare const plivoEndCall: (uuid: string) => Promise<void>;
|
|
10
10
|
export declare const downloadRecord: (url_pub: string) => Promise<void>;
|
|
11
11
|
export declare const getPlivoAccessToken: () => Promise<any>;
|
|
12
|
+
export declare const createSipAccount: (data: {
|
|
13
|
+
did_number: string;
|
|
14
|
+
sip_username: string;
|
|
15
|
+
}) => Promise<any>;
|