vue-wiguet-chatweb 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-wiguet-chatweb",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -29,6 +29,7 @@
29
29
  "build": "vue-tsc && vite build",
30
30
  "preview": "vite preview",
31
31
  "test:unit": "vitest",
32
+ "coverage": "vitest --coverage",
32
33
  "prepack": "npm run build"
33
34
  },
34
35
  "peerDependencies": {
@@ -54,6 +55,7 @@
54
55
  "@types/node": "^20.4.6",
55
56
  "@types/uuid": "^10.0.0",
56
57
  "@vitejs/plugin-vue": "^5.2.1",
58
+ "@vitest/coverage-v8": "^2.1.8",
57
59
  "jsdom": "^25.0.1",
58
60
  "typescript": "^5.0.2",
59
61
  "vite": "^5.4.11",
@@ -21,9 +21,6 @@
21
21
  <div class="w-full">
22
22
  <form class="message-send" @submit.prevent="submitMessage">
23
23
  <div class="form-message">
24
- <!-- <button type="submit">
25
- <IconUser />
26
- </button> -->
27
24
  <div class="jl-inputgroup-chat">
28
25
  <textarea
29
26
  v-model="message"
@@ -56,7 +53,6 @@ import {
56
53
  } from "../dto/app.dto";
57
54
  import IconClose from "./IconClose.vue";
58
55
  import IconSend from "./IconSend.vue";
59
- // import IconUser from "./IconUser.vue";
60
56
  import {
61
57
  getMessagesApi,
62
58
  sendMessageApi,
@@ -66,7 +62,7 @@ import { getInformationApi } from "../store";
66
62
  import MessageList from "./MessageList.vue";
67
63
  import Loader from "./Loader.vue";
68
64
  import { searchFromLast } from "../resources/functions.helpers";
69
- import { io } from "socket.io-client";
65
+ import { io, Socket } from "socket.io-client";
70
66
  import { APP_TYPE } from "../dto/chat.dto";
71
67
 
72
68
  //DATA
@@ -188,7 +184,7 @@ const submitMessage = async (event: Event) => {
188
184
  messagesData.value.data[idx] = newMsg;
189
185
 
190
186
  const message = {...newMsg, chatId:newMessage.chatId }
191
- socketService.value.emit(
187
+ socketService.value?.emit(
192
188
  'sendMessage',
193
189
  { roomId: information?.value?.appChat.id, message },
194
190
  (response: any) => {
@@ -262,7 +258,7 @@ const retryMessage = async (message: Message) => {
262
258
 
263
259
  messagesData.value.data[idx] = { ...msg, error: undefined };
264
260
 
265
- socketService.value.emit(
261
+ socketService.value?.emit(
266
262
  'sendMessage',
267
263
  { roomId: information?.value?.appChat.id, message },
268
264
  );
@@ -304,7 +300,7 @@ function autoAdjustHeight() {
304
300
  textAreaRef.value.style.height = textAreaRef.value.scrollHeight + "px"
305
301
  }
306
302
 
307
- const socketService = ref();
303
+ const socketService = ref<Socket>();
308
304
  const information = ref<ChatInformation>();
309
305
 
310
306
  function connectMsWebSocket (userChat: ChatInformation ,app: APP_TYPE = APP_TYPE.WEBCHAT) {
@@ -319,10 +315,12 @@ function connectMsWebSocket (userChat: ChatInformation ,app: APP_TYPE = APP_TYPE
319
315
  extraHeaders: { Authorization: props.tokenAuth },
320
316
  });
321
317
 
318
+ socketService.value.removeAllListeners();
319
+
322
320
  socketService.value.on('connect', () => {
323
321
  console.log('Conectado al servidor de sockets');
324
322
 
325
- socketService.value.emit(
323
+ socketService.value?.emit(
326
324
  'joinRoom',
327
325
  `${userChat?.appChat?.id}`
328
326
  );
@@ -336,10 +334,11 @@ function connectMsWebSocket (userChat: ChatInformation ,app: APP_TYPE = APP_TYPE
336
334
  console.log('Mensaje recibido:', data.message, userChat);
337
335
 
338
336
  if (data.message.sender.msPersonaId === userChat?.chat?.persona?.msPersonaId) return
339
-
337
+
340
338
  messagesData.value.data.push(data.message);
341
339
  setVistoToTrueApi(data.message.appChatId, props.tokenAuth);
342
340
  scrollToBottom();
341
+ !props.visible && emit("new-message");
343
342
  });
344
343
  }
345
344
 
@@ -359,7 +358,7 @@ onMounted(async () => {
359
358
  });
360
359
 
361
360
  onUnmounted(() => {
362
- socketService.value.off();
361
+ socketService.value?.off();
363
362
  });
364
363
  </script>
365
364
 
@@ -1,5 +1,6 @@
1
1
  import { expect, it } from 'vitest'
2
+ import Chat from '../Chat.vue'
2
3
 
3
- it('renders correctly', () => {
4
- expect(2).toBeTruthy()
4
+ it('definido', () => {
5
+ expect(Chat).toBeDefined()
5
6
  })
@@ -0,0 +1,6 @@
1
+ import { expect, it } from 'vitest'
2
+ import ChatMessage from '../ChatMessage.vue'
3
+
4
+ it('definido', () => {
5
+ expect(ChatMessage).toBeDefined()
6
+ })
@@ -1,6 +0,0 @@
1
- <template>
2
- <svg width="42" height="42" viewBox="0 0 42 42" fill="none" xmlns="http://www.w3.org/2000/svg">
3
- <path d="M21.04 40.9399C32.0857 40.9399 41.04 31.9856 41.04 20.9399C41.04 9.89419 32.0857 0.939941 21.04 0.939941C9.99428 0.939941 1.03998 9.89419 1.03998 20.9399C1.03998 31.9856 9.99428 40.9399 21.04 40.9399Z" stroke="#F28B0C" stroke-width="1.5" stroke-miterlimit="10"/>
4
- <path d="M22.87 20.36C24.92 19.57 26.38 17.5801 26.38 15.2601C26.38 12.2401 23.93 9.79004 20.91 9.79004C17.89 9.79004 15.44 12.2401 15.44 15.2601C15.44 17.6301 16.95 19.6401 19.06 20.4001C16.15 21.2601 14.02 23.9501 14.02 27.1301V31.7701C14.02 31.9401 14.16 32.08 14.33 32.08H27.76C27.93 32.08 28.07 31.9401 28.07 31.7701V27.1301C28.07 23.8901 25.86 21.16 22.87 20.36Z" fill="#F28B0C"/>
5
- </svg>
6
- </template>