@phonghq/go-chat 1.0.52 → 1.0.53

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.
@@ -819,7 +819,6 @@ else {
819
819
  hideNumpad: (__VLS_ctx.isLib),
820
820
  responsive: (__VLS_ctx.responsiveRender),
821
821
  ...{ class: "bg-white shrink-0 border-l layout-border" },
822
- modelValue: "",
823
822
  }));
824
823
  const __VLS_119 = __VLS_118({
825
824
  ...{ 'onCall': {} },
@@ -827,7 +826,6 @@ else {
827
826
  hideNumpad: (__VLS_ctx.isLib),
828
827
  responsive: (__VLS_ctx.responsiveRender),
829
828
  ...{ class: "bg-white shrink-0 border-l layout-border" },
830
- modelValue: "",
831
829
  }, ...__VLS_functionalComponentArgsRest(__VLS_118));
832
830
  let __VLS_121;
833
831
  let __VLS_122;
@@ -25,6 +25,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
25
25
  color: string;
26
26
  is_unknown: number;
27
27
  customer_id?: number | undefined;
28
+ tenant_id?: number | undefined;
28
29
  }[], IConversation[] | {
29
30
  id: number;
30
31
  receiver_id: number;
@@ -40,6 +41,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
40
41
  color: string;
41
42
  is_unknown: number;
42
43
  customer_id?: number | undefined;
44
+ tenant_id?: number | undefined;
43
45
  }[]>;
44
46
  listConversationsUnknown: import("vue").Ref<{
45
47
  id: number;
@@ -56,6 +58,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
56
58
  color: string;
57
59
  is_unknown: number;
58
60
  customer_id?: number | undefined;
61
+ tenant_id?: number | undefined;
59
62
  }[], IConversation[] | {
60
63
  id: number;
61
64
  receiver_id: number;
@@ -71,6 +74,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
71
74
  color: string;
72
75
  is_unknown: number;
73
76
  customer_id?: number | undefined;
77
+ tenant_id?: number | undefined;
74
78
  }[]>;
75
79
  getCurrentConversation: () => IConversation | undefined;
76
80
  initData: (option?: {
@@ -193,10 +193,10 @@ const initData = async (option) => {
193
193
  selectUser(conversation);
194
194
  }
195
195
  }
196
- handleTabChange(TAB_VALUE.ALL, { hideCheckHasReceiveId: activeTabs.value != TAB_VALUE.UNKNOWN });
197
- handleTabChange(TAB_VALUE.UNKNOWN, {
198
- hideCheckHasReceiveId,
199
- hideLoading: activeTabs.value != TAB_VALUE.UNKNOWN
196
+ handleTabChange(activeTabs.value, { hideCheckHasReceiveId: hideCheckHasReceiveId });
197
+ handleTabChange(activeTabs.value == 1 ? 0 : 1, {
198
+ hideCheckHasReceiveId: true,
199
+ hideLoading: true
200
200
  });
201
201
  };
202
202
  const __VLS_exposed = {
@@ -6,7 +6,7 @@ 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_DETAIL_CHAT, TOPIC_PLIVO_SMS } from '../../../constant/mqtt';
9
+ import { 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';
@@ -31,11 +31,11 @@ onUnmounted(() => {
31
31
  const handleConnectMqtt = async () => {
32
32
  try {
33
33
  await connectMqtt();
34
- topic = TOPIC_DETAIL_CHAT + infoUser.value?.conversation_id;
34
+ // topic = TOPIC_DETAIL_CHAT + infoUser.value?.conversation_id
35
35
  topic_plivo_chat = TOPIC_PLIVO_SMS + infoUser.value?.conversation_id;
36
- subscribeToTopic(topic);
36
+ // subscribeToTopic(topic)
37
37
  subscribeToTopic(topic_plivo_chat);
38
- addHandleMqttMessage('chat-home', topic, mqttMessageHandler);
38
+ // addHandleMqttMessage('chat-home', topic, mqttMessageHandler)
39
39
  addHandleMqttMessage('chat-home-1', topic_plivo_chat, mqttMessageHandler);
40
40
  }
41
41
  catch (error) {
@@ -43,9 +43,9 @@ const handleConnectMqtt = async () => {
43
43
  }
44
44
  };
45
45
  const handleDisconnectMqtt = async () => {
46
- unsubscribeFromTopic(topic);
46
+ // unsubscribeFromTopic(topic)
47
47
  unsubscribeFromTopic(topic_plivo_chat);
48
- removeHandleMqttMessage('chat-home');
48
+ // removeHandleMqttMessage('chat-home')
49
49
  removeHandleMqttMessage('chat-home-1');
50
50
  };
51
51
  const mqttMessageHandler = (topic, message) => {
@@ -146,10 +146,10 @@ const handleSendMessage = async (data) => {
146
146
  // listMessage.value.push({ ...data, state: MessageState.Sending })
147
147
  listMessage.value.unshift({ ...data, state: MessageState.Sending });
148
148
  await nextTick();
149
- publishMessage(topic, {
150
- ...data,
151
- state: MessageState.Sending
152
- });
149
+ // publishMessage(topic, {
150
+ // ...data,
151
+ // state: MessageState.Sending
152
+ // })
153
153
  let file_upload = [];
154
154
  if (data?.attachments?.length) {
155
155
  updateMessageItem(data.id, { state: MessageState.Uploading });
@@ -164,7 +164,7 @@ const handleSendMessage = async (data) => {
164
164
  formData.append('url', file_upload[0]?.url ?? '');
165
165
  }
166
166
  await sendMessage(formData);
167
- publishMessage(topic, {
167
+ publishMessage(topic_plivo_chat, {
168
168
  ...data,
169
169
  state: MessageState.Sent,
170
170
  attachments: file_upload
@@ -50,36 +50,35 @@ if (__VLS_ctx.responsive == 'window') {
50
50
  let __VLS_4;
51
51
  const __VLS_5 = ({ call: {} },
52
52
  { onCall: (__VLS_ctx.handleCall) });
53
+ var __VLS_6 = {};
53
54
  // @ts-ignore
54
55
  [responsive, hideNumpad, handleCall,];
55
56
  var __VLS_2;
56
57
  }
57
- if (__VLS_ctx.responsive != 'window') {
58
- // @ts-ignore
59
- [responsive,];
58
+ else {
60
59
  /** @type {[typeof DrawerBaseCustom, typeof DrawerBaseCustom, ]} */ ;
61
60
  // @ts-ignore
62
- const __VLS_7 = __VLS_asFunctionalComponent(DrawerBaseCustom, new DrawerBaseCustom({
61
+ const __VLS_8 = __VLS_asFunctionalComponent(DrawerBaseCustom, new DrawerBaseCustom({
63
62
  ref: "drawerVisibleRef",
64
63
  responsive: (__VLS_ctx.responsive),
65
64
  }));
66
- const __VLS_8 = __VLS_7({
65
+ const __VLS_9 = __VLS_8({
67
66
  ref: "drawerVisibleRef",
68
67
  responsive: (__VLS_ctx.responsive),
69
- }, ...__VLS_functionalComponentArgsRest(__VLS_7));
68
+ }, ...__VLS_functionalComponentArgsRest(__VLS_8));
70
69
  /** @type {typeof __VLS_ctx.drawerVisibleRef} */ ;
71
- var __VLS_10 = {};
72
- const { default: __VLS_12 } = __VLS_9.slots;
70
+ var __VLS_11 = {};
71
+ const { default: __VLS_13 } = __VLS_10.slots;
73
72
  // @ts-ignore
74
73
  [responsive, drawerVisibleRef,];
75
74
  {
76
- const { content: __VLS_13 } = __VLS_9.slots;
75
+ const { content: __VLS_14 } = __VLS_10.slots;
77
76
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
78
77
  ...{ class: "h-full flex flex-col" },
79
78
  });
80
79
  /** @type {[typeof PhoneNumpad, ]} */ ;
81
80
  // @ts-ignore
82
- const __VLS_14 = __VLS_asFunctionalComponent(PhoneNumpad, new PhoneNumpad({
81
+ const __VLS_15 = __VLS_asFunctionalComponent(PhoneNumpad, new PhoneNumpad({
83
82
  ...{ 'onCall': {} },
84
83
  ...{ 'onBack': {} },
85
84
  ref: "phoneNumpadRef",
@@ -87,33 +86,33 @@ if (__VLS_ctx.responsive != 'window') {
87
86
  hideNumpad: (__VLS_ctx.hideNumpad),
88
87
  responsive: (__VLS_ctx.responsive),
89
88
  }));
90
- const __VLS_15 = __VLS_14({
89
+ const __VLS_16 = __VLS_15({
91
90
  ...{ 'onCall': {} },
92
91
  ...{ 'onBack': {} },
93
92
  ref: "phoneNumpadRef",
94
93
  ...{ class: "bg-white grow border-l layout-border w-full" },
95
94
  hideNumpad: (__VLS_ctx.hideNumpad),
96
95
  responsive: (__VLS_ctx.responsive),
97
- }, ...__VLS_functionalComponentArgsRest(__VLS_14));
98
- let __VLS_17;
96
+ }, ...__VLS_functionalComponentArgsRest(__VLS_15));
99
97
  let __VLS_18;
100
- const __VLS_19 = ({ call: {} },
98
+ let __VLS_19;
99
+ const __VLS_20 = ({ call: {} },
101
100
  { onCall: (__VLS_ctx.handleCall) });
102
- const __VLS_20 = ({ back: {} },
101
+ const __VLS_21 = ({ back: {} },
103
102
  { onBack: (...[$event]) => {
104
- if (!(__VLS_ctx.responsive != 'window'))
103
+ if (!!(__VLS_ctx.responsive == 'window'))
105
104
  return;
106
105
  __VLS_ctx.drawerVisibleRef?.close();
107
106
  // @ts-ignore
108
107
  [responsive, hideNumpad, handleCall, drawerVisibleRef,];
109
108
  } });
110
109
  /** @type {typeof __VLS_ctx.phoneNumpadRef} */ ;
111
- var __VLS_21 = {};
110
+ var __VLS_22 = {};
112
111
  // @ts-ignore
113
112
  [phoneNumpadRef,];
114
- var __VLS_16;
113
+ var __VLS_17;
115
114
  }
116
- var __VLS_9;
115
+ var __VLS_10;
117
116
  }
118
117
  /** @type {__VLS_StyleScopedClasses['bg-white']} */ ;
119
118
  /** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
@@ -128,7 +127,7 @@ if (__VLS_ctx.responsive != 'window') {
128
127
  /** @type {__VLS_StyleScopedClasses['layout-border']} */ ;
129
128
  /** @type {__VLS_StyleScopedClasses['w-full']} */ ;
130
129
  // @ts-ignore
131
- var __VLS_11 = __VLS_10, __VLS_22 = __VLS_21;
130
+ var __VLS_12 = __VLS_11, __VLS_23 = __VLS_22;
132
131
  const __VLS_export = (await import('vue')).defineComponent({
133
132
  setup: () => (__VLS_exposed),
134
133
  __typeEmits: {},
@@ -15,6 +15,7 @@ export declare const useListConversations: (is_unknown: number, is_tenant: boole
15
15
  color: string;
16
16
  is_unknown: number;
17
17
  customer_id?: number | undefined;
18
+ tenant_id?: number | undefined;
18
19
  }[], IConversation[] | {
19
20
  id: number;
20
21
  receiver_id: number;
@@ -30,6 +31,7 @@ export declare const useListConversations: (is_unknown: number, is_tenant: boole
30
31
  color: string;
31
32
  is_unknown: number;
32
33
  customer_id?: number | undefined;
34
+ tenant_id?: number | undefined;
33
35
  }[]>;
34
36
  params: import("vue").Ref<{
35
37
  page: number;
@@ -1,6 +1,6 @@
1
1
  import { nextTick, onMounted, onUnmounted, ref } from 'vue';
2
- import { TOPIC_HOME, TOPIC_STATUS_USER } from '../constant/mqtt';
3
- import { addHandleMqttMessage, connectMqtt, removeHandleMqttMessage, subscribeToTopic, unsubscribeFromTopic } from '../plugins/mqtt';
2
+ import { TOPIC_HOME } from '../constant/mqtt';
3
+ import { addHandleMqttMessage, connectMqtt, publishMessage, removeHandleMqttMessage, subscribeToTopic, unsubscribeFromTopic } from '../plugins/mqtt';
4
4
  import { dataProfile } from '../utils/chat/store/auth';
5
5
  import { useDebounce } from '../utils/debounce';
6
6
  import { getConversation } from '../utils/chat/store/conversation';
@@ -29,8 +29,8 @@ export const useListConversations = (is_unknown, is_tenant) => {
29
29
  removeHandleMqttMessage('chat-list-' + item + '-' + is_unknown);
30
30
  });
31
31
  if (dataProfile.value?.user_type == 'tenant') {
32
- subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id);
33
- removeHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown);
32
+ // unsubscribeFromTopic(TOPIC_STATUS_USER + dataProfile.value?.id)
33
+ // removeHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown)
34
34
  }
35
35
  };
36
36
  const handleConnectMqtt = async () => {
@@ -38,12 +38,17 @@ export const useListConversations = (is_unknown, is_tenant) => {
38
38
  if (dataProfile.value) {
39
39
  await connectMqtt();
40
40
  TOPIC_HOME.forEach((item) => {
41
- console.log(item + dataProfile.value?.id);
42
- subscribeToTopic(item + dataProfile.value?.id);
41
+ if (is_unknown == 0) {
42
+ subscribeToTopic(item + dataProfile.value?.id);
43
+ }
43
44
  addHandleMqttMessage('chat-list-' + item + '-' + is_unknown, item + dataProfile.value?.id, mqttMessageHandler);
44
45
  });
45
- subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id);
46
- addHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown, TOPIC_STATUS_USER + dataProfile.value?.id, mqttMessageHandler);
46
+ // subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id)
47
+ // addHandleMqttMessage(
48
+ // 'chat-list-' + TOPIC_STATUS_USER + '-' + is_unknown,
49
+ // TOPIC_STATUS_USER + dataProfile.value?.id,
50
+ // mqttMessageHandler
51
+ // )
47
52
  }
48
53
  }
49
54
  catch (error) {
@@ -53,11 +58,14 @@ export const useListConversations = (is_unknown, is_tenant) => {
53
58
  const mqttMessageHandler = (topic, data) => {
54
59
  if ((data.is_unknown ?? 0) == is_unknown || (!is_tenant && is_unknown == 0)) {
55
60
  getDataMqtt();
56
- if (topic === TOPIC_HOME[0] + dataProfile.value?.id ||
57
- topic === TOPIC_HOME[3] + dataProfile.value?.id) {
61
+ if (topic ===
62
+ TOPIC_HOME[0] + dataProfile.value?.id
63
+ // ||topic === TOPIC_HOME[3] + dataProfile.value?.id
64
+ ) {
58
65
  const index = listConversations.value.findIndex((item) => item.id === data.id);
59
66
  const hasChatBox = listConversations.value.findIndex((item) => item.id === digibotId);
60
67
  if (index != -1) {
68
+ data.username = listConversations.value[index].username ?? '';
61
69
  listConversations.value.splice(index, 1);
62
70
  }
63
71
  if (hasChatBox > -1) {
@@ -68,20 +76,24 @@ export const useListConversations = (is_unknown, is_tenant) => {
68
76
  }
69
77
  }
70
78
  if (topic === TOPIC_HOME[1] + dataProfile.value?.id) {
71
- const index = listConversations.value.findIndex((item) => item.id === data.id);
72
- if (index != -1) {
73
- listConversations.value[index].unread_count = 0;
74
- }
75
- }
76
- if (topic === TOPIC_HOME[2] + dataProfile.value?.id) {
77
- listConversations.value.unshift(data?.conversations);
78
- }
79
- if (topic === TOPIC_STATUS_USER + dataProfile.value?.id) {
80
- const index = listConversations.value.findIndex((e) => e.receiver_id == Number(data?.customer_id));
81
- if (index != -1) {
82
- listConversations.value[index].status = data.is_online ? 1 : 0;
79
+ if (data.is_unknown == is_unknown) {
80
+ const index = listConversations.value.findIndex((item) => item.id === data.id);
81
+ if (index != -1) {
82
+ listConversations.value[index].unread_count = 0;
83
+ }
83
84
  }
84
85
  }
86
+ // if (topic === TOPIC_HOME[2] + dataProfile.value?.id) {
87
+ // listConversations.value.unshift(data?.conversations)
88
+ // }
89
+ // if (topic === TOPIC_STATUS_USER + dataProfile.value?.id) {
90
+ // const index = listConversations.value.findIndex(
91
+ // (e) => e.receiver_id == Number(data?.customer_id)
92
+ // )
93
+ // if (index != -1) {
94
+ // listConversations.value[index].status = data.is_online ? 1 : 0
95
+ // }
96
+ // }
85
97
  }
86
98
  };
87
99
  const getDataMqtt = useDebounce(() => {
@@ -131,6 +143,7 @@ export const useListConversations = (is_unknown, is_tenant) => {
131
143
  if (listConversations.value[index].unread_count) {
132
144
  readMessages(listConversations.value[index].id);
133
145
  listConversations.value[index].unread_count = 0;
146
+ publishMessage(TOPIC_HOME[1] + dataProfile.value?.id, listConversations.value[index]);
134
147
  }
135
148
  }
136
149
  };
@@ -3,10 +3,11 @@ export const TOPIC_DETAIL_CALL = 'call/message/';
3
3
  export const TOPIC_PLIVO_SMS = 'sms-inbound/';
4
4
  export const TOPIC_STATUS_USER = 'user/status/';
5
5
  export const TOPIC_HOME = [
6
- 'chat/conversation/update/',
6
+ // 'chat/conversation/update/',
7
+ // 'chat/conversation/read_message/',
8
+ // 'chat/conversation/update_list/',
9
+ 'chat/conversation/update/sms-inbound/',
7
10
  'chat/conversation/read_message/',
8
- 'chat/conversation/update_list/',
9
- 'chat/conversation/update/sms-inbound/'
10
11
  ];
11
12
  // export CALL_STATE = {
12
13
  // Offer: 'offer',