vue-wiguet-chatweb 0.0.18 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/components/Chat.vue +13 -10
- package/src/components/MessageList.vue +12 -5
package/package.json
CHANGED
package/src/components/Chat.vue
CHANGED
@@ -129,14 +129,16 @@ watch(
|
|
129
129
|
);
|
130
130
|
onMounted(async () => {
|
131
131
|
if (!virtualHost.value || !appChatId.value) {
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
132
|
+
try {
|
133
|
+
const resp = await getInformationApi(props.tokenAuth);
|
134
|
+
const data = resp.response.data;
|
135
|
+
virtualHost.value = data.virtualHost;
|
136
|
+
appChatId.value = data.appChat.id;
|
137
|
+
emit("not-viewed-total", data.appChat.totalNoVistosCliente);
|
138
|
+
notViewed.value = data.appChat.totalNoVistosCliente;
|
139
|
+
getMessages();
|
140
|
+
connectMsRabbit();
|
141
|
+
} catch (error) {}
|
140
142
|
}
|
141
143
|
});
|
142
144
|
|
@@ -210,7 +212,7 @@ const getMessages = async () => {
|
|
210
212
|
isLoading.value = true;
|
211
213
|
const lastMessagesId = messagesData.value.data[0]?.id;
|
212
214
|
const body: ListMessageBody = {
|
213
|
-
|
215
|
+
size: 10,
|
214
216
|
lastMessagesId,
|
215
217
|
appChatId: appChatId.value,
|
216
218
|
};
|
@@ -220,7 +222,7 @@ const getMessages = async () => {
|
|
220
222
|
...resp.data.sort((a, b) => -b.createdAt.localeCompare(a.createdAt))
|
221
223
|
);
|
222
224
|
messagesData.value.canLoadMoreMessages =
|
223
|
-
resp.pagination.total > resp.pagination.
|
225
|
+
resp.pagination.total > resp.pagination.size;
|
224
226
|
if (lastMessagesId && messageContainerRef.value?.scrollHeight) {
|
225
227
|
mantainElementsOnViewport(messageContainerRef.value?.scrollHeight);
|
226
228
|
}
|
@@ -284,6 +286,7 @@ const connectMsRabbit = (app: any = "webchat") => {
|
|
284
286
|
notViewed.value = notViewed.value + 1;
|
285
287
|
emit("new-message");
|
286
288
|
}
|
289
|
+
scrollToBottom();
|
287
290
|
}
|
288
291
|
});
|
289
292
|
};
|
@@ -5,10 +5,13 @@
|
|
5
5
|
v-for="message in props.messages"
|
6
6
|
:key="message.id"
|
7
7
|
class="message"
|
8
|
-
:class="message.esCliente ? 'message-
|
8
|
+
:class="message.esCliente ? 'message-right' : 'message-left'"
|
9
9
|
>
|
10
10
|
<div class="message-container">
|
11
|
-
<div
|
11
|
+
<div
|
12
|
+
v-if="message.error && message.esCliente"
|
13
|
+
class="btn-container-widget"
|
14
|
+
>
|
12
15
|
<button
|
13
16
|
text
|
14
17
|
rounded
|
@@ -21,14 +24,18 @@
|
|
21
24
|
</button>
|
22
25
|
</div>
|
23
26
|
<div class="chat-message">
|
24
|
-
<div class="bubble" :class="message.esCliente ? '
|
25
|
-
<div :class="message.esCliente ? 'content-
|
27
|
+
<div class="bubble" :class="message.esCliente ? 'right' : 'left'">
|
28
|
+
<div :class="message.esCliente ? 'content-right' : 'content-left'">
|
26
29
|
<div class="message-text">
|
27
30
|
{{ message.message }}
|
28
31
|
</div>
|
29
32
|
<div class="detail-message flex justify-content-between">
|
30
33
|
<span class="mr-5" v-if="message.sender?.nombreCompleto">
|
31
|
-
{{
|
34
|
+
{{
|
35
|
+
message.esCliente
|
36
|
+
? message.sender?.nombreCompleto
|
37
|
+
: "ECOSISTEMA JL"
|
38
|
+
}}
|
32
39
|
</span>
|
33
40
|
<span class="mr-5" v-else> </span>
|
34
41
|
<span>
|