@phonghq/go-chat 1.0.33 → 1.0.35

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.
@@ -203,7 +203,7 @@ const __VLS_5 = ({ search: {} },
203
203
  [responsive, keyword, handleSearch,];
204
204
  var __VLS_2;
205
205
  __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
206
- ...{ class: "h-11 w-11 rounded-full flex-center bg-[#C7DEFF]" },
206
+ ...{ class: "shrink-0 h-11 w-11 rounded-full flex-center bg-[#C7DEFF]" },
207
207
  });
208
208
  /** @type {[typeof IconPlus, ]} */ ;
209
209
  // @ts-ignore
@@ -341,7 +341,7 @@ for (const [user] of __VLS_getVForSourceType((__VLS_ctx.listConversations))) {
341
341
  });
342
342
  (user.last_message ?? 'No messages');
343
343
  __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
344
- ...{ class: "shrink-0 text-sm text-right text-chat-gray-4 w-[130px]" },
344
+ ...{ class: "shrink-0 text-sm text-right text-chat-gray-4 w-[80px] md:w-[130px]" },
345
345
  });
346
346
  (__VLS_ctx.getTimeFromNow(user.last_message_time ?? ''));
347
347
  // @ts-ignore
@@ -362,6 +362,7 @@ var __VLS_20;
362
362
  /** @type {__VLS_StyleScopedClasses['mb-4']} */ ;
363
363
  /** @type {__VLS_StyleScopedClasses['h-11']} */ ;
364
364
  /** @type {__VLS_StyleScopedClasses['grow']} */ ;
365
+ /** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
365
366
  /** @type {__VLS_StyleScopedClasses['h-11']} */ ;
366
367
  /** @type {__VLS_StyleScopedClasses['w-11']} */ ;
367
368
  /** @type {__VLS_StyleScopedClasses['rounded-full']} */ ;
@@ -417,7 +418,8 @@ var __VLS_20;
417
418
  /** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
418
419
  /** @type {__VLS_StyleScopedClasses['text-right']} */ ;
419
420
  /** @type {__VLS_StyleScopedClasses['text-chat-gray-4']} */ ;
420
- /** @type {__VLS_StyleScopedClasses['w-[130px]']} */ ;
421
+ /** @type {__VLS_StyleScopedClasses['w-[80px]']} */ ;
422
+ /** @type {__VLS_StyleScopedClasses['md:w-[130px]']} */ ;
421
423
  // @ts-ignore
422
424
  var __VLS_25 = __VLS_24;
423
425
  const __VLS_export = (await import('vue')).defineComponent({
@@ -32,6 +32,8 @@ const handleConnectMqtt = async () => {
32
32
  topic_plivo_chat = TOPIC_PLIVO_SMS + infoUser.value?.conversation_id;
33
33
  subscribeToTopic(topic);
34
34
  subscribeToTopic(topic_plivo_chat);
35
+ // console.log(topic)
36
+ // console.log(topic_plivo_chat)
35
37
  addHandleMqttMessage('chat-home', topic, mqttMessageHandler);
36
38
  }
37
39
  catch (error) {
@@ -35,18 +35,24 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
35
35
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
36
36
  ...{ class: "flex items-center gap-2" },
37
37
  });
38
- __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
39
- ...{ onClick: (...[$event]) => {
40
- __VLS_ctx.emit('back');
41
- // @ts-ignore
42
- [emit,];
43
- } },
44
- ...{ class: "shrink-0 flex items-center" },
45
- });
46
- /** @type {[typeof IconArrowLeft, ]} */ ;
47
- // @ts-ignore
48
- const __VLS_0 = __VLS_asFunctionalComponent(IconArrowLeft, new IconArrowLeft({}));
49
- const __VLS_1 = __VLS_0({}, ...__VLS_functionalComponentArgsRest(__VLS_0));
38
+ if (__VLS_ctx.responsive == 'mobile') {
39
+ // @ts-ignore
40
+ [responsive,];
41
+ __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
42
+ ...{ onClick: (...[$event]) => {
43
+ if (!(__VLS_ctx.responsive == 'mobile'))
44
+ return;
45
+ __VLS_ctx.emit('back');
46
+ // @ts-ignore
47
+ [emit,];
48
+ } },
49
+ ...{ class: "shrink-0 flex items-center" },
50
+ });
51
+ /** @type {[typeof IconArrowLeft, ]} */ ;
52
+ // @ts-ignore
53
+ const __VLS_0 = __VLS_asFunctionalComponent(IconArrowLeft, new IconArrowLeft({}));
54
+ const __VLS_1 = __VLS_0({}, ...__VLS_functionalComponentArgsRest(__VLS_0));
55
+ }
50
56
  /** @type {[typeof Avatar, ]} */ ;
51
57
  // @ts-ignore
52
58
  const __VLS_4 = __VLS_asFunctionalComponent(Avatar, new Avatar({
@@ -45,6 +45,7 @@ const handleSendMessage = async (type) => {
45
45
  attachments = [{ file_name: String(tempId), file_path, file_local: file }];
46
46
  }
47
47
  keyword.value = '';
48
+ // chatInputRef.value.style.height = 'auto'
48
49
  chatId++;
49
50
  const id = props.data?.id.toString() + '-' + chatId;
50
51
  const data = {
@@ -86,14 +87,20 @@ const handleActivePlivoSmsChange = async (is_active) => {
86
87
  }
87
88
  loading.value = false;
88
89
  };
89
- const setInputHeight = () => {
90
+ const setInputHeight = (e) => {
90
91
  const el = chatInputRef.value;
91
92
  el.style.height = 'auto';
92
- el.style.height = el.scrollHeight + 'px';
93
+ if (keyword.value?.replace(/\s+/g, "") == '') {
94
+ el.style.height = 42 + 'px';
95
+ keyword.value = '';
96
+ }
97
+ else {
98
+ el.style.height = el.scrollHeight + 'px';
99
+ }
93
100
  };
94
- const handleSetInputHeight = useDebounce(() => {
95
- setInputHeight();
96
- }, 50);
101
+ const handleSetInputHeight = useDebounce((e) => {
102
+ setInputHeight(e);
103
+ }, 200);
97
104
  const handleInput = () => {
98
105
  emit('focus');
99
106
  };
@@ -177,14 +184,14 @@ __VLS_asFunctionalElement(__VLS_elements.textarea)({
177
184
  [handleInput,];
178
185
  } },
179
186
  ...{ onInput: (...[$event]) => {
180
- __VLS_ctx.setInputHeight();
187
+ __VLS_ctx.setInputHeight($event);
181
188
  // @ts-ignore
182
189
  [setInputHeight,];
183
190
  } },
184
- ...{ class: "w-full min-h-11 resize-none overflow-hidden chat-input !rounded-xl pl-4 py-2 pr-[96px] border border-chat-haze-200" },
191
+ ...{ class: "w-full min-h-11 overflow-hidden chat-input !rounded-xl pl-4 py-2 pr-[96px] border border-chat-haze-200" },
185
192
  ref: "chatInputRef",
186
- placeholder: "Send Message",
187
193
  rows: "1",
194
+ placeholder: "Send Message",
188
195
  value: (__VLS_ctx.keyword),
189
196
  });
190
197
  /** @type {typeof __VLS_ctx.chatInputRef} */ ;
@@ -294,7 +301,6 @@ const __VLS_29 = __VLS_28({
294
301
  /** @type {__VLS_StyleScopedClasses['grow']} */ ;
295
302
  /** @type {__VLS_StyleScopedClasses['w-full']} */ ;
296
303
  /** @type {__VLS_StyleScopedClasses['min-h-11']} */ ;
297
- /** @type {__VLS_StyleScopedClasses['resize-none']} */ ;
298
304
  /** @type {__VLS_StyleScopedClasses['overflow-hidden']} */ ;
299
305
  /** @type {__VLS_StyleScopedClasses['chat-input']} */ ;
300
306
  /** @type {__VLS_StyleScopedClasses['!rounded-xl']} */ ;
@@ -36,7 +36,6 @@ const isPhoneMatchDial = (countryDial, phone) => {
36
36
  };
37
37
  const onSubmit = async () => {
38
38
  try {
39
- console.log(isPhoneMatchDial(selected.value.dial, phoneValue.value));
40
39
  if (!nameValue.value) {
41
40
  error.value = `Business name is required.`;
42
41
  return;
@@ -44,6 +44,9 @@ const handlePlivoCallBack = (status, data) => {
44
44
  callStatus.value = status;
45
45
  startTimer();
46
46
  }
47
+ else if (status == PLIVO_CALL_STATUS.MEDIA_PERMISSION_FAIL) {
48
+ emit('error:mediaPermissionFail');
49
+ }
47
50
  };
48
51
  const { plivoLogin, plivoCallAnswer, plivoCall, plivoEndCall, plivoCallSwishMute } = usePlivo(handlePlivoCallBack);
49
52
  const STATUS_LABEL = computed(() => {
@@ -57,7 +60,8 @@ const STATUS_LABEL = computed(() => {
57
60
  [PLIVO_CALL_STATUS.NO_ANSWER]: 'No Answer',
58
61
  [PLIVO_CALL_STATUS.CANCEL]: '',
59
62
  [PLIVO_CALL_STATUS.TIME_OUT]: '',
60
- [PLIVO_CALL_STATUS.BUSY]: ''
63
+ [PLIVO_CALL_STATUS.BUSY]: '',
64
+ [PLIVO_CALL_STATUS.MEDIA_PERMISSION_FAIL]: ''
61
65
  };
62
66
  });
63
67
  const label = computed(() => STATUS_LABEL.value[callStatus.value] ?? '');
@@ -37,9 +37,12 @@ export function usePlivo(callback) {
37
37
  plivoBrowserSdk?.client?.on?.('onLoginFailed', (e) => handleLoginFailed(e));
38
38
  // plivoBrowserSdk?.client?.on?.('remoteAudioStatus', () => console.log('remoteAudioStatus'))
39
39
  const payload = JSON.parse(atob(token.split('.')[1]));
40
- // await plivoBrowserSdk?.client?.tokenLogin(username, token)
40
+ // console.log(payload)
41
+ // await plivoBrowserSdk?.client?.tokenLogin(payload.sub ?? '', token)
41
42
  // await plivoBrowserSdk?.client?.login('webcall003079673454891827', '123456abcA!')
43
+ // await plivoBrowserSdk?.client?.login(payload.sub , null, token)
42
44
  await plivoBrowserSdk?.client?.loginWithAccessToken(token);
45
+ // await plivoBrowserSdk?.client?.on?.(payload)
43
46
  // console.log('Registered with token')
44
47
  }
45
48
  catch (err) {
@@ -143,6 +146,9 @@ export function usePlivo(callback) {
143
146
  };
144
147
  const handleMediaPermission = (e) => {
145
148
  console.log('MediaPermission', e);
149
+ if (e?.status == 'failure') {
150
+ callback(PLIVO_CALL_STATUS.MEDIA_PERMISSION_FAIL);
151
+ }
146
152
  };
147
153
  return {
148
154
  plivoLogin,
@@ -17,5 +17,6 @@ export const PLIVO_CALL_STATUS = {
17
17
  NO_ANSWER: 'no-answer',
18
18
  CANCEL: 'cancel',
19
19
  TIME_OUT: 'timeout',
20
- BUSY: 'busy'
20
+ BUSY: 'busy',
21
+ MEDIA_PERMISSION_FAIL: 'media-permission-fail',
21
22
  };
@@ -43,9 +43,9 @@ export const checkTenantPhone = async () => {
43
43
  const res = await axios.get(`/api/v1/message/tenant/get-info?tenant_name=${id}`);
44
44
  if (res.error || !res?.data)
45
45
  throw new Error(res.error);
46
- // if(dataProfile.value) dataProfile.value.tenant_phone = res?.data?.go_chat_phone ?? ''
47
46
  if (dataProfile.value)
48
- dataProfile.value.tenant_phone = '';
47
+ dataProfile.value.tenant_phone = res?.data?.go_chat_phone ?? '';
48
+ // if(dataProfile.value) dataProfile.value.tenant_phone = ''
49
49
  if (dataProfile.value)
50
50
  dataProfile.value.tenant_phone_limit = Number(res?.data?.go_chat_phone_limit ?? 0);
51
51
  return res;
@@ -53,7 +53,6 @@ export const checkTenantPhone = async () => {
53
53
  export const submitTenantPhone = async (body) => {
54
54
  const res = await axios.post('/api/v1/message/tenant/update-phone', body);
55
55
  dataLoginLink.value = res;
56
- console.log(res);
57
56
  return res;
58
57
  };
59
58
  export const logout = async () => {
@@ -13,5 +13,6 @@ export declare const PLIVO_CALL_STATUS: {
13
13
  readonly CANCEL: "cancel";
14
14
  readonly TIME_OUT: "timeout";
15
15
  readonly BUSY: "busy";
16
+ readonly MEDIA_PERMISSION_FAIL: "media-permission-fail";
16
17
  };
17
18
  export type PlivoCallStatusType = (typeof PLIVO_CALL_STATUS)[keyof typeof PLIVO_CALL_STATUS];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phonghq/go-chat",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"