@phonghq/go-chat 1.0.3 → 1.0.4
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/go-chat.es.js +6578 -6530
- package/dist/go-chat.umd.js +14 -14
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/assets/icons/IconArrowLeft.vue.d.ts +0 -2
- package/dist/assets/icons/IconPhone.vue.d.ts +0 -2
- package/dist/assets/icons/IconPlan.vue.d.ts +0 -2
- package/dist/assets/icons/IconPlus.vue.d.ts +0 -2
- package/dist/assets/icons/IconSearch.vue.d.ts +0 -32
- package/dist/assets/icons/call/IconMic.vue.d.ts +0 -14
- package/dist/assets/icons/call/IconPhone.vue.d.ts +0 -2
- package/dist/assets/icons/call/IconPhoneCancel.vue.d.ts +0 -2
- package/dist/assets/icons/call/IconSpeaker.vue.d.ts +0 -14
- package/dist/assets/icons/customer-appointment/IconFilter.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconArrow.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconCheck.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconDate.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconGroup.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconMessage.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconNote.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconPhone.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconPin.vue.d.ts +0 -2
- package/dist/assets/icons/customer-detail/IconSearch.vue.d.ts +0 -2
- package/dist/chat/App.vue.d.ts +0 -5
- package/dist/chat/main.d.ts +0 -6
- package/dist/chat/page/customer-appointment/CustomerAppointment.vue.d.ts +0 -2
- package/dist/chat/page/customer-check-in/CollapseCheckIn.vue.d.ts +0 -12
- package/dist/chat/page/customer-check-in/CustomerCheckIn.vue.d.ts +0 -2
- package/dist/chat/page/customer-detail/CustomerDetail.vue.d.ts +0 -7
- package/dist/chat/page/customer-detail/SubInformation.vue.d.ts +0 -16
- package/dist/chat/page/error/Error.vue.d.ts +0 -2
- package/dist/chat/page/home/ChatList.vue.d.ts +0 -20
- package/dist/chat/page/home/ChatMessage.vue.d.ts +0 -16
- package/dist/chat/page/home/Home.vue.d.ts +0 -14
- package/dist/chat/page/home/HomeHeader.vue.d.ts +0 -10
- package/dist/chat/page/home/InputChat.vue.d.ts +0 -19
- package/dist/chat/page/home/NewCustomer.vue.d.ts +0 -6
- package/dist/components/ListenEvent.vue.d.ts +0 -2
- package/dist/components/chat/ScrollEvent/ScrollEvent.vue.d.ts +0 -22
- package/dist/components/chat/call/Calling.vue.d.ts +0 -7
- package/dist/components/chat/card/CardCustomerDetail.vue.d.ts +0 -13
- package/dist/components/chat/common/collapse/CollapseBase.vue.d.ts +0 -20
- package/dist/components/chat/common/input/InputSearch.vue.d.ts +0 -16
- package/dist/components/chat/common/popover/PopoverBase.vue.d.ts +0 -35
- package/dist/components/chat/common/spin/BaseSpin.vue.d.ts +0 -2
- package/dist/components/chat/customer/Avatar.vue.d.ts +0 -11
- package/dist/components/chat/layout/mobile/Footer.vue.d.ts +0 -2
- package/dist/components/common/CustomLoading.vue.d.ts +0 -2
- package/dist/components/common/Notification/NotificationDescription.vue.d.ts +0 -7
- package/dist/components/common/button/ButtonBase.vue.d.ts +0 -22
- package/dist/components/common/button/ButtonToggle.vue.d.ts +0 -20
- package/dist/components/common/checkbox/CCheckboxNumber.vue.d.ts +0 -16
- package/dist/components/common/collapse/BaseCollapse.vue.d.ts +0 -12
- package/dist/components/common/collapse/BaseCollapseItem.vue.d.ts +0 -4
- package/dist/components/common/drawer/DrawerBase.vue.d.ts +0 -39
- package/dist/components/common/dropdown/DropdownBase.vue.d.ts +0 -21
- package/dist/components/common/input/CInputSearch.vue.d.ts +0 -14
- package/dist/components/common/modal/ModalBase.vue.d.ts +0 -35
- package/dist/components/common/popover/PopoverBase.vue.d.ts +0 -3
- package/dist/components/common/slider/BaseSlider.vue.d.ts +0 -11
- package/dist/components/common/spin/CSpin.vue.d.ts +0 -9
- package/dist/components/common/tooltip/TooltipBase.vue.d.ts +0 -2
- package/dist/components/layout/Blank.vue.d.ts +0 -9
- package/dist/components/layout/Default.vue.d.ts +0 -9
- package/dist/components/modal/Confirm.vue.d.ts +0 -2
- package/dist/components/ui/button/CButton.vue.d.ts +0 -19
- package/dist/components/ui/button/c-button.d.ts +0 -7
- package/dist/components/ui/checkbox/Checkbox.vue.d.ts +0 -18
- package/dist/components/ui/checkbox/index.d.ts +0 -1
- package/dist/components/ui/collapsible/Collapsible.vue.d.ts +0 -16
- package/dist/components/ui/collapsible/CollapsibleContent.vue.d.ts +0 -10
- package/dist/components/ui/collapsible/CollapsibleTrigger.vue.d.ts +0 -10
- package/dist/components/ui/collapsible/index.d.ts +0 -3
- package/dist/components/ui/dialog/Dialog.vue.d.ts +0 -14
- package/dist/components/ui/dialog/DialogClose.vue.d.ts +0 -10
- package/dist/components/ui/dialog/DialogContent.vue.d.ts +0 -29
- package/dist/components/ui/dialog/DialogDescription.vue.d.ts +0 -14
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts +0 -13
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts +0 -13
- package/dist/components/ui/dialog/DialogScrollContent.vue.d.ts +0 -30
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts +0 -14
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +0 -10
- package/dist/components/ui/dialog/index.d.ts +0 -9
- package/dist/components/ui/drawer/Drawer.vue.d.ts +0 -26
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts +0 -33
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts +0 -14
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts +0 -13
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts +0 -13
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts +0 -7
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts +0 -14
- package/dist/components/ui/drawer/index.d.ts +0 -8
- package/dist/components/ui/dropdown-menu/DropdownMenu.vue.d.ts +0 -14
- package/dist/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.d.ts +0 -20
- package/dist/components/ui/dropdown-menu/DropdownMenuContent.vue.d.ts +0 -28
- package/dist/components/ui/dropdown-menu/DropdownMenuGroup.vue.d.ts +0 -10
- package/dist/components/ui/dropdown-menu/DropdownMenuItem.vue.d.ts +0 -15
- package/dist/components/ui/dropdown-menu/DropdownMenuLabel.vue.d.ts +0 -15
- package/dist/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue.d.ts +0 -14
- package/dist/components/ui/dropdown-menu/DropdownMenuRadioItem.vue.d.ts +0 -18
- package/dist/components/ui/dropdown-menu/DropdownMenuSeparator.vue.d.ts +0 -7
- package/dist/components/ui/dropdown-menu/DropdownMenuShortcut.vue.d.ts +0 -13
- package/dist/components/ui/dropdown-menu/DropdownMenuSub.vue.d.ts +0 -14
- package/dist/components/ui/dropdown-menu/DropdownMenuSubContent.vue.d.ts +0 -30
- package/dist/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +0 -14
- package/dist/components/ui/dropdown-menu/DropdownMenuTrigger.vue.d.ts +0 -10
- package/dist/components/ui/dropdown-menu/index.d.ts +0 -15
- package/dist/components/ui/popover/Popover.vue.d.ts +0 -14
- package/dist/components/ui/popover/PopoverContent.vue.d.ts +0 -28
- package/dist/components/ui/popover/PopoverTrigger.vue.d.ts +0 -10
- package/dist/components/ui/popover/index.d.ts +0 -3
- package/dist/components/ui/radio-group/RadioGroup.vue.d.ts +0 -18
- package/dist/components/ui/radio-group/RadioGroupItem.vue.d.ts +0 -7
- package/dist/components/ui/radio-group/index.d.ts +0 -2
- package/dist/components/ui/slider/Slider.vue.d.ts +0 -13
- package/dist/components/ui/slider/index.d.ts +0 -1
- package/dist/components/ui/switch/Switch.vue.d.ts +0 -18
- package/dist/components/ui/switch/index.d.ts +0 -1
- package/dist/composable/useCallHelper.d.ts +0 -23
- package/dist/composable/useInitData.d.ts +0 -11
- package/dist/composable/useModalConfirm.d.ts +0 -5
- package/dist/constant/color.d.ts +0 -22
- package/dist/constant/datetime.d.ts +0 -5
- package/dist/constant/general.d.ts +0 -8
- package/dist/constant/message.d.ts +0 -8
- package/dist/constant/mqtt.d.ts +0 -4
- package/dist/constant/user.d.ts +0 -8
- package/dist/lib/utils.d.ts +0 -2
- package/dist/plugins/axios-gci.d.ts +0 -3
- package/dist/plugins/axios.d.ts +0 -3
- package/dist/plugins/mqtt.d.ts +0 -10
- package/dist/plugins/sdk.d.ts +0 -19
- package/dist/plugins/websocket.d.ts +0 -4
- package/dist/test/assets/icons/IconArrowLeft.vue.js +0 -29
- package/dist/test/assets/icons/IconPhone.vue.js +0 -19
- package/dist/test/assets/icons/IconPlan.vue.js +0 -19
- package/dist/test/assets/icons/IconPlus.vue.js +0 -22
- package/dist/test/assets/icons/IconSearch.vue.js +0 -68
- package/dist/test/assets/icons/call/IconMic.vue.js +0 -123
- package/dist/test/assets/icons/call/IconPhone.vue.js +0 -35
- package/dist/test/assets/icons/call/IconPhoneCancel.vue.js +0 -35
- package/dist/test/assets/icons/call/IconSpeaker.vue.js +0 -62
- package/dist/test/assets/icons/customer-appointment/IconFilter.vue.js +0 -53
- package/dist/test/assets/icons/customer-detail/IconArrow.vue.js +0 -22
- package/dist/test/assets/icons/customer-detail/IconCheck.vue.js +0 -27
- package/dist/test/assets/icons/customer-detail/IconDate.vue.js +0 -43
- package/dist/test/assets/icons/customer-detail/IconGroup.vue.js +0 -48
- package/dist/test/assets/icons/customer-detail/IconMessage.vue.js +0 -28
- package/dist/test/assets/icons/customer-detail/IconNote.vue.js +0 -29
- package/dist/test/assets/icons/customer-detail/IconPhone.vue.js +0 -21
- package/dist/test/assets/icons/customer-detail/IconPin.vue.js +0 -29
- package/dist/test/assets/icons/customer-detail/IconSearch.vue.js +0 -29
- package/dist/test/chat/App.vue.js +0 -502
- package/dist/test/chat/main.js +0 -6
- package/dist/test/chat/page/customer-appointment/CustomerAppointment.vue.js +0 -207
- package/dist/test/chat/page/customer-check-in/CollapseCheckIn.vue.js +0 -80
- package/dist/test/chat/page/customer-check-in/CustomerCheckIn.vue.js +0 -136
- package/dist/test/chat/page/customer-detail/CustomerDetail.vue.js +0 -235
- package/dist/test/chat/page/customer-detail/SubInformation.vue.js +0 -102
- package/dist/test/chat/page/error/Error.vue.js +0 -64
- package/dist/test/chat/page/home/ChatList.vue.js +0 -380
- package/dist/test/chat/page/home/ChatMessage.vue.js +0 -271
- package/dist/test/chat/page/home/Home.vue.js +0 -327
- package/dist/test/chat/page/home/HomeHeader.vue.js +0 -122
- package/dist/test/chat/page/home/InputChat.vue.js +0 -226
- package/dist/test/chat/page/home/NewCustomer.vue.js +0 -82
- package/dist/test/components/ListenEvent.vue.js +0 -45
- package/dist/test/components/chat/ScrollEvent/ScrollEvent.vue.js +0 -197
- package/dist/test/components/chat/call/Calling.vue.js +0 -291
- package/dist/test/components/chat/card/CardCustomerDetail.vue.js +0 -28
- package/dist/test/components/chat/common/collapse/CollapseBase.vue.js +0 -59
- package/dist/test/components/chat/common/input/InputSearch.vue.js +0 -71
- package/dist/test/components/chat/common/popover/PopoverBase.vue.js +0 -148
- package/dist/test/components/chat/common/spin/BaseSpin.vue.js +0 -12
- package/dist/test/components/chat/customer/Avatar.vue.js +0 -79
- package/dist/test/components/chat/layout/mobile/Footer.vue.js +0 -109
- package/dist/test/components/common/CustomLoading.vue.js +0 -19
- package/dist/test/components/common/Notification/NotificationDescription.vue.js +0 -38
- package/dist/test/components/common/button/ButtonBase.vue.js +0 -78
- package/dist/test/components/common/button/ButtonToggle.vue.js +0 -70
- package/dist/test/components/common/checkbox/CCheckboxNumber.vue.js +0 -48
- package/dist/test/components/common/collapse/BaseCollapse.vue.js +0 -36
- package/dist/test/components/common/collapse/BaseCollapseItem.vue.js +0 -22
- package/dist/test/components/common/drawer/DrawerBase.vue.js +0 -126
- package/dist/test/components/common/dropdown/DropdownBase.vue.js +0 -91
- package/dist/test/components/common/input/CInputSearch.vue.js +0 -62
- package/dist/test/components/common/modal/ModalBase.vue.js +0 -164
- package/dist/test/components/common/popover/PopoverBase.vue.js +0 -36
- package/dist/test/components/common/slider/BaseSlider.vue.js +0 -70
- package/dist/test/components/common/spin/CSpin.vue.js +0 -41
- package/dist/test/components/common/tooltip/TooltipBase.vue.js +0 -8
- package/dist/test/components/layout/Blank.vue.js +0 -19
- package/dist/test/components/layout/Default.vue.js +0 -21
- package/dist/test/components/modal/Confirm.vue.js +0 -164
- package/dist/test/components/ui/button/CButton.vue.js +0 -49
- package/dist/test/components/ui/button/c-button.js +0 -26
- package/dist/test/components/ui/checkbox/Checkbox.vue.js +0 -79
- package/dist/test/components/ui/checkbox/index.js +0 -1
- package/dist/test/components/ui/collapsible/Collapsible.vue.js +0 -47
- package/dist/test/components/ui/collapsible/CollapsibleContent.vue.js +0 -41
- package/dist/test/components/ui/collapsible/CollapsibleTrigger.vue.js +0 -35
- package/dist/test/components/ui/collapsible/index.js +0 -3
- package/dist/test/components/ui/dialog/Dialog.vue.js +0 -42
- package/dist/test/components/ui/dialog/DialogClose.vue.js +0 -35
- package/dist/test/components/ui/dialog/DialogContent.vue.js +0 -84
- package/dist/test/components/ui/dialog/DialogDescription.vue.js +0 -43
- package/dist/test/components/ui/dialog/DialogFooter.vue.js +0 -26
- package/dist/test/components/ui/dialog/DialogHeader.vue.js +0 -26
- package/dist/test/components/ui/dialog/DialogScrollContent.vue.js +0 -99
- package/dist/test/components/ui/dialog/DialogTitle.vue.js +0 -43
- package/dist/test/components/ui/dialog/DialogTrigger.vue.js +0 -35
- package/dist/test/components/ui/dialog/index.js +0 -9
- package/dist/test/components/ui/drawer/Drawer.vue.js +0 -48
- package/dist/test/components/ui/drawer/DrawerContent.vue.js +0 -81
- package/dist/test/components/ui/drawer/DrawerDescription.vue.js +0 -42
- package/dist/test/components/ui/drawer/DrawerFooter.vue.js +0 -26
- package/dist/test/components/ui/drawer/DrawerHeader.vue.js +0 -26
- package/dist/test/components/ui/drawer/DrawerOverlay.vue.js +0 -37
- package/dist/test/components/ui/drawer/DrawerTitle.vue.js +0 -42
- package/dist/test/components/ui/drawer/index.js +0 -8
- package/dist/test/components/ui/dropdown-menu/DropdownMenu.vue.js +0 -41
- package/dist/test/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.js +0 -79
- package/dist/test/components/ui/dropdown-menu/DropdownMenuContent.vue.js +0 -61
- package/dist/test/components/ui/dropdown-menu/DropdownMenuGroup.vue.js +0 -35
- package/dist/test/components/ui/dropdown-menu/DropdownMenuItem.vue.js +0 -43
- package/dist/test/components/ui/dropdown-menu/DropdownMenuLabel.vue.js +0 -43
- package/dist/test/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue.js +0 -41
- package/dist/test/components/ui/dropdown-menu/DropdownMenuRadioItem.vue.js +0 -80
- package/dist/test/components/ui/dropdown-menu/DropdownMenuSeparator.vue.js +0 -37
- package/dist/test/components/ui/dropdown-menu/DropdownMenuShortcut.vue.js +0 -26
- package/dist/test/components/ui/dropdown-menu/DropdownMenuSub.vue.js +0 -41
- package/dist/test/components/ui/dropdown-menu/DropdownMenuSubContent.vue.js +0 -46
- package/dist/test/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue.js +0 -58
- package/dist/test/components/ui/dropdown-menu/DropdownMenuTrigger.vue.js +0 -41
- package/dist/test/components/ui/dropdown-menu/index.js +0 -15
- package/dist/test/components/ui/popover/Popover.vue.js +0 -41
- package/dist/test/components/ui/popover/PopoverContent.vue.js +0 -60
- package/dist/test/components/ui/popover/PopoverTrigger.vue.js +0 -35
- package/dist/test/components/ui/popover/index.js +0 -3
- package/dist/test/components/ui/radio-group/RadioGroup.vue.js +0 -46
- package/dist/test/components/ui/radio-group/RadioGroupItem.vue.js +0 -71
- package/dist/test/components/ui/radio-group/index.js +0 -2
- package/dist/test/components/ui/slider/Slider.vue.js +0 -155
- package/dist/test/components/ui/slider/index.js +0 -1
- package/dist/test/components/ui/switch/Switch.vue.js +0 -61
- package/dist/test/components/ui/switch/index.js +0 -1
- package/dist/test/composable/useCallHelper.js +0 -170
- package/dist/test/composable/useInitData.js +0 -84
- package/dist/test/composable/useModalConfirm.js +0 -39
- package/dist/test/constant/color.js +0 -43
- package/dist/test/constant/datetime.js +0 -5
- package/dist/test/constant/general.js +0 -9
- package/dist/test/constant/message.js +0 -8
- package/dist/test/constant/mqtt.js +0 -11
- package/dist/test/constant/user.js +0 -9
- package/dist/test/lib/utils.js +0 -5
- package/dist/test/plugins/axios-gci.js +0 -25
- package/dist/test/plugins/axios.js +0 -85
- package/dist/test/plugins/mqtt.js +0 -128
- package/dist/test/plugins/sdk.js +0 -83
- package/dist/test/plugins/websocket.js +0 -65
- package/dist/test/types/call.js +0 -1
- package/dist/test/types/chat/auth.js +0 -1
- package/dist/test/types/chat/global.js +0 -1
- package/dist/test/types/chat/promise.js +0 -1
- package/dist/test/types/chat/user.js +0 -1
- package/dist/test/types/conversation.js +0 -1
- package/dist/test/types/global.js +0 -15
- package/dist/test/types/message.js +0 -1
- package/dist/test/utils/chat/auth.js +0 -51
- package/dist/test/utils/chat/call.js +0 -61
- package/dist/test/utils/chat/chat-router.js +0 -9
- package/dist/test/utils/chat/conversation.js +0 -7
- package/dist/test/utils/chat/message.js +0 -42
- package/dist/test/utils/chat/user.js +0 -33
- package/dist/test/utils/debounce.js +0 -9
- package/dist/test/utils/json.js +0 -18
- package/dist/test/utils/logger.js +0 -5
- package/dist/test/utils/string-helper.js +0 -27
- package/dist/types/call.d.ts +0 -4
- package/dist/types/chat/auth.d.ts +0 -37
- package/dist/types/chat/global.d.ts +0 -7
- package/dist/types/chat/promise.d.ts +0 -17
- package/dist/types/chat/user.d.ts +0 -88
- package/dist/types/conversation.d.ts +0 -18
- package/dist/types/global.d.ts +0 -11
- package/dist/types/message.d.ts +0 -43
- package/dist/utils/chat/auth.d.ts +0 -45
- package/dist/utils/chat/call.d.ts +0 -5
- package/dist/utils/chat/chat-router.d.ts +0 -3
- package/dist/utils/chat/conversation.d.ts +0 -3
- package/dist/utils/chat/message.d.ts +0 -17
- package/dist/utils/chat/user.d.ts +0 -193
- package/dist/utils/debounce.d.ts +0 -1
- package/dist/utils/json.d.ts +0 -2
- package/dist/utils/logger.d.ts +0 -3
- package/dist/utils/string-helper.d.ts +0 -1
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
/// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
|
|
2
|
-
import Avatar from '../../../components/chat/customer/Avatar.vue';
|
|
3
|
-
import { dataProfile } from '../../../utils/chat/auth';
|
|
4
|
-
import { nextTick, ref } from 'vue';
|
|
5
|
-
import ScrollEvent from '../../../components/chat/ScrollEvent/ScrollEvent.vue';
|
|
6
|
-
import { MessageState } from '../../../constant/message';
|
|
7
|
-
const props = withDefaults(defineProps(), {});
|
|
8
|
-
const emit = defineEmits();
|
|
9
|
-
const scrollEventRef = ref(null);
|
|
10
|
-
const scrollBottom = () => {
|
|
11
|
-
nextTick(() => {
|
|
12
|
-
const eleIdContentChat = document.getElementById('content-chat');
|
|
13
|
-
if (eleIdContentChat) {
|
|
14
|
-
eleIdContentChat.scrollTop = eleIdContentChat.scrollHeight;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
const shouldShowAvatar = (index) => {
|
|
19
|
-
if (index === 0)
|
|
20
|
-
return true;
|
|
21
|
-
return props.message[index - 1].sender_id !== props.message[index].sender_id;
|
|
22
|
-
};
|
|
23
|
-
const isEndMessage = (index) => {
|
|
24
|
-
if (props.message?.length == index + 1)
|
|
25
|
-
return true;
|
|
26
|
-
return props.message[index + 1].sender_id !== props.message[index].sender_id;
|
|
27
|
-
};
|
|
28
|
-
const handleScrollTop = () => {
|
|
29
|
-
emit('scrollTop');
|
|
30
|
-
};
|
|
31
|
-
const hideScrollEvent = () => {
|
|
32
|
-
scrollEventRef.value?.hideLoading();
|
|
33
|
-
scrollEventRef.value?.fixedScroll();
|
|
34
|
-
};
|
|
35
|
-
const getMessageStateText = (item) => {
|
|
36
|
-
const state = item.state;
|
|
37
|
-
switch (state) {
|
|
38
|
-
case MessageState.Sending:
|
|
39
|
-
return 'Sending...';
|
|
40
|
-
case MessageState.Uploading:
|
|
41
|
-
return 'Uploading...';
|
|
42
|
-
case MessageState.Sent:
|
|
43
|
-
return '';
|
|
44
|
-
case MessageState.Read:
|
|
45
|
-
return 'Seen';
|
|
46
|
-
case MessageState.Failed:
|
|
47
|
-
return item.error || 'Message failed';
|
|
48
|
-
default:
|
|
49
|
-
return '';
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const __VLS_exposed = { scrollBottom, hideScrollEvent };
|
|
53
|
-
defineExpose(__VLS_exposed);
|
|
54
|
-
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
|
55
|
-
const __VLS_defaults = {};
|
|
56
|
-
const __VLS_ctx = {
|
|
57
|
-
...{},
|
|
58
|
-
...{},
|
|
59
|
-
...{},
|
|
60
|
-
...{},
|
|
61
|
-
...{},
|
|
62
|
-
};
|
|
63
|
-
let __VLS_elements;
|
|
64
|
-
let __VLS_components;
|
|
65
|
-
let __VLS_directives;
|
|
66
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
67
|
-
...{ class: "relative overflow-hidden" },
|
|
68
|
-
});
|
|
69
|
-
/** @type {[typeof ScrollEvent, typeof ScrollEvent, ]} */ ;
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
const __VLS_0 = __VLS_asFunctionalComponent(ScrollEvent, new ScrollEvent({
|
|
72
|
-
...{ 'onGetDataTop': {} },
|
|
73
|
-
...{ class: "bg-white h-full flex flex-col overflow-auto" },
|
|
74
|
-
id: "content-chat",
|
|
75
|
-
top: true,
|
|
76
|
-
ref: "scrollEventRef",
|
|
77
|
-
}));
|
|
78
|
-
const __VLS_1 = __VLS_0({
|
|
79
|
-
...{ 'onGetDataTop': {} },
|
|
80
|
-
...{ class: "bg-white h-full flex flex-col overflow-auto" },
|
|
81
|
-
id: "content-chat",
|
|
82
|
-
top: true,
|
|
83
|
-
ref: "scrollEventRef",
|
|
84
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_0));
|
|
85
|
-
let __VLS_3;
|
|
86
|
-
let __VLS_4;
|
|
87
|
-
const __VLS_5 = ({ getDataTop: {} },
|
|
88
|
-
{ onGetDataTop: (__VLS_ctx.handleScrollTop) });
|
|
89
|
-
/** @type {typeof __VLS_ctx.scrollEventRef} */ ;
|
|
90
|
-
var __VLS_6 = {};
|
|
91
|
-
const { default: __VLS_8 } = __VLS_2.slots;
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
[handleScrollTop, scrollEventRef,];
|
|
94
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
95
|
-
...{ class: "chat-padding-page" },
|
|
96
|
-
});
|
|
97
|
-
for (const [item, index] of __VLS_getVForSourceType((__VLS_ctx.message))) {
|
|
98
|
-
(item.id);
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
[message,];
|
|
101
|
-
if (item.sender_id !== __VLS_ctx.dataProfile?.id) {
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
[dataProfile,];
|
|
104
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
105
|
-
...{ class: "flex items-end gap-2 mt-2" },
|
|
106
|
-
...{ class: ({ 'mt-4': __VLS_ctx.shouldShowAvatar(index) }) },
|
|
107
|
-
});
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
[shouldShowAvatar,];
|
|
110
|
-
if (item.state != __VLS_ctx.MessageState.Sending) {
|
|
111
|
-
// @ts-ignore
|
|
112
|
-
[MessageState,];
|
|
113
|
-
if (__VLS_ctx.shouldShowAvatar(index)) {
|
|
114
|
-
// @ts-ignore
|
|
115
|
-
[shouldShowAvatar,];
|
|
116
|
-
/** @type {[typeof Avatar, ]} */ ;
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
const __VLS_9 = __VLS_asFunctionalComponent(Avatar, new Avatar({
|
|
119
|
-
src: (__VLS_ctx.data?.avatar ?? ''),
|
|
120
|
-
color: (__VLS_ctx.data?.color),
|
|
121
|
-
name: (__VLS_ctx.data?.username),
|
|
122
|
-
size: (__VLS_ctx.response == 'mobile' ? 'sm' : 'md'),
|
|
123
|
-
...{ class: (__VLS_ctx.response == 'mobile' ? 'translate-y-[-2px]' : '') },
|
|
124
|
-
}));
|
|
125
|
-
const __VLS_10 = __VLS_9({
|
|
126
|
-
src: (__VLS_ctx.data?.avatar ?? ''),
|
|
127
|
-
color: (__VLS_ctx.data?.color),
|
|
128
|
-
name: (__VLS_ctx.data?.username),
|
|
129
|
-
size: (__VLS_ctx.response == 'mobile' ? 'sm' : 'md'),
|
|
130
|
-
...{ class: (__VLS_ctx.response == 'mobile' ? 'translate-y-[-2px]' : '') },
|
|
131
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_9));
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
[data, data, data, response, response,];
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
137
|
-
...{ class: (__VLS_ctx.response == 'mobile' ? 'w-8' : 'w-12') },
|
|
138
|
-
});
|
|
139
|
-
// @ts-ignore
|
|
140
|
-
[response,];
|
|
141
|
-
}
|
|
142
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
143
|
-
...{ class: "bg-[#E4E4E4D4] text-chat-haze-600 px-3 py-2 rounded-2xl max-w-xs" },
|
|
144
|
-
...{ class: ({
|
|
145
|
-
'rounded-tl-none': !__VLS_ctx.shouldShowAvatar(index),
|
|
146
|
-
'rounded-bl-none': !__VLS_ctx.isEndMessage(index)
|
|
147
|
-
}) },
|
|
148
|
-
});
|
|
149
|
-
// @ts-ignore
|
|
150
|
-
[shouldShowAvatar, isEndMessage,];
|
|
151
|
-
if (item.message) {
|
|
152
|
-
__VLS_asFunctionalElement(__VLS_elements.div)({
|
|
153
|
-
...{ style: ({ wordBreak: 'break-word' }) },
|
|
154
|
-
});
|
|
155
|
-
__VLS_asFunctionalDirective(__VLS_directives.vHtml)(null, { ...__VLS_directiveBindingRestFields, value: (item.message) }, null, null);
|
|
156
|
-
}
|
|
157
|
-
else if (item.attachments.length) {
|
|
158
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({});
|
|
159
|
-
__VLS_asFunctionalElement(__VLS_elements.img)({
|
|
160
|
-
...{ onLoad: (() => {
|
|
161
|
-
if (index == __VLS_ctx.message.length - 1) {
|
|
162
|
-
__VLS_ctx.scrollBottom();
|
|
163
|
-
}
|
|
164
|
-
}) },
|
|
165
|
-
src: (item.attachments[0]?.file_path),
|
|
166
|
-
alt: "avatar",
|
|
167
|
-
});
|
|
168
|
-
// @ts-ignore
|
|
169
|
-
[message, scrollBottom,];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
175
|
-
...{ class: "flex flex-col items-end mt-2" },
|
|
176
|
-
...{ class: ({ 'mt-4': __VLS_ctx.shouldShowAvatar(index) }) },
|
|
177
|
-
});
|
|
178
|
-
// @ts-ignore
|
|
179
|
-
[shouldShowAvatar,];
|
|
180
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
181
|
-
...{ class: "bg-[#D0DFEC] text-[#266699] px-3 py-2 rounded-2xl max-w-xs" },
|
|
182
|
-
...{ class: ({
|
|
183
|
-
'rounded-tr-none': !__VLS_ctx.shouldShowAvatar(index),
|
|
184
|
-
'rounded-br-none': !__VLS_ctx.isEndMessage(index)
|
|
185
|
-
}) },
|
|
186
|
-
});
|
|
187
|
-
// @ts-ignore
|
|
188
|
-
[shouldShowAvatar, isEndMessage,];
|
|
189
|
-
if (item.message) {
|
|
190
|
-
__VLS_asFunctionalElement(__VLS_elements.div)({
|
|
191
|
-
...{ style: ({ wordBreak: 'break-word' }) },
|
|
192
|
-
});
|
|
193
|
-
__VLS_asFunctionalDirective(__VLS_directives.vHtml)(null, { ...__VLS_directiveBindingRestFields, value: (item.message) }, null, null);
|
|
194
|
-
}
|
|
195
|
-
else if (item?.attachments?.length) {
|
|
196
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({});
|
|
197
|
-
__VLS_asFunctionalElement(__VLS_elements.img)({
|
|
198
|
-
...{ onLoad: (() => {
|
|
199
|
-
if (index == __VLS_ctx.message.length - 1) {
|
|
200
|
-
__VLS_ctx.scrollBottom();
|
|
201
|
-
}
|
|
202
|
-
}) },
|
|
203
|
-
src: (item.attachments[0]?.file_path),
|
|
204
|
-
alt: "avatar",
|
|
205
|
-
});
|
|
206
|
-
// @ts-ignore
|
|
207
|
-
[message, scrollBottom,];
|
|
208
|
-
}
|
|
209
|
-
if ((index == __VLS_ctx.message.length - 1 && __VLS_ctx.getMessageStateText(item)) || item.state == __VLS_ctx.MessageState.Failed) {
|
|
210
|
-
// @ts-ignore
|
|
211
|
-
[message, MessageState, getMessageStateText,];
|
|
212
|
-
__VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
|
|
213
|
-
...{ class: "text-chat-haze-200 text-xs mt-1" },
|
|
214
|
-
...{ class: ({ 'text-danger': item.state == __VLS_ctx.MessageState.Failed }) },
|
|
215
|
-
});
|
|
216
|
-
// @ts-ignore
|
|
217
|
-
[MessageState,];
|
|
218
|
-
(__VLS_ctx.getMessageStateText(item));
|
|
219
|
-
// @ts-ignore
|
|
220
|
-
[getMessageStateText,];
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
var __VLS_2;
|
|
225
|
-
/** @type {__VLS_StyleScopedClasses['relative']} */ ;
|
|
226
|
-
/** @type {__VLS_StyleScopedClasses['overflow-hidden']} */ ;
|
|
227
|
-
/** @type {__VLS_StyleScopedClasses['bg-white']} */ ;
|
|
228
|
-
/** @type {__VLS_StyleScopedClasses['h-full']} */ ;
|
|
229
|
-
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
230
|
-
/** @type {__VLS_StyleScopedClasses['flex-col']} */ ;
|
|
231
|
-
/** @type {__VLS_StyleScopedClasses['overflow-auto']} */ ;
|
|
232
|
-
/** @type {__VLS_StyleScopedClasses['chat-padding-page']} */ ;
|
|
233
|
-
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
234
|
-
/** @type {__VLS_StyleScopedClasses['items-end']} */ ;
|
|
235
|
-
/** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
|
|
236
|
-
/** @type {__VLS_StyleScopedClasses['mt-2']} */ ;
|
|
237
|
-
/** @type {__VLS_StyleScopedClasses['mt-4']} */ ;
|
|
238
|
-
/** @type {__VLS_StyleScopedClasses['bg-[#E4E4E4D4]']} */ ;
|
|
239
|
-
/** @type {__VLS_StyleScopedClasses['text-chat-haze-600']} */ ;
|
|
240
|
-
/** @type {__VLS_StyleScopedClasses['px-3']} */ ;
|
|
241
|
-
/** @type {__VLS_StyleScopedClasses['py-2']} */ ;
|
|
242
|
-
/** @type {__VLS_StyleScopedClasses['rounded-2xl']} */ ;
|
|
243
|
-
/** @type {__VLS_StyleScopedClasses['max-w-xs']} */ ;
|
|
244
|
-
/** @type {__VLS_StyleScopedClasses['rounded-tl-none']} */ ;
|
|
245
|
-
/** @type {__VLS_StyleScopedClasses['rounded-bl-none']} */ ;
|
|
246
|
-
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
247
|
-
/** @type {__VLS_StyleScopedClasses['flex-col']} */ ;
|
|
248
|
-
/** @type {__VLS_StyleScopedClasses['items-end']} */ ;
|
|
249
|
-
/** @type {__VLS_StyleScopedClasses['mt-2']} */ ;
|
|
250
|
-
/** @type {__VLS_StyleScopedClasses['mt-4']} */ ;
|
|
251
|
-
/** @type {__VLS_StyleScopedClasses['bg-[#D0DFEC]']} */ ;
|
|
252
|
-
/** @type {__VLS_StyleScopedClasses['text-[#266699]']} */ ;
|
|
253
|
-
/** @type {__VLS_StyleScopedClasses['px-3']} */ ;
|
|
254
|
-
/** @type {__VLS_StyleScopedClasses['py-2']} */ ;
|
|
255
|
-
/** @type {__VLS_StyleScopedClasses['rounded-2xl']} */ ;
|
|
256
|
-
/** @type {__VLS_StyleScopedClasses['max-w-xs']} */ ;
|
|
257
|
-
/** @type {__VLS_StyleScopedClasses['rounded-tr-none']} */ ;
|
|
258
|
-
/** @type {__VLS_StyleScopedClasses['rounded-br-none']} */ ;
|
|
259
|
-
/** @type {__VLS_StyleScopedClasses['text-chat-haze-200']} */ ;
|
|
260
|
-
/** @type {__VLS_StyleScopedClasses['text-xs']} */ ;
|
|
261
|
-
/** @type {__VLS_StyleScopedClasses['mt-1']} */ ;
|
|
262
|
-
/** @type {__VLS_StyleScopedClasses['text-danger']} */ ;
|
|
263
|
-
// @ts-ignore
|
|
264
|
-
var __VLS_7 = __VLS_6;
|
|
265
|
-
const __VLS_export = (await import('vue')).defineComponent({
|
|
266
|
-
setup: () => (__VLS_exposed),
|
|
267
|
-
__typeEmits: {},
|
|
268
|
-
__typeProps: {},
|
|
269
|
-
props: {},
|
|
270
|
-
});
|
|
271
|
-
export default {};
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
/// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
|
|
2
|
-
import HomeHeader from '../../../chat/page/home/HomeHeader.vue';
|
|
3
|
-
import NewCustomer from '../../../chat/page/home/NewCustomer.vue';
|
|
4
|
-
import InputChat from '../../../chat/page/home/InputChat.vue';
|
|
5
|
-
import { getCountUnread, getDetailReceiver, getMessage, sendMessage, upLoadImage } from '../../../utils/chat/message';
|
|
6
|
-
import { nextTick, onMounted, onUnmounted, ref, shallowRef } from 'vue';
|
|
7
|
-
import ChatMessage from '../../../chat/page/home/ChatMessage.vue';
|
|
8
|
-
import { addHandleMqttMessage, connectMqtt, publishMessage, removeHandleMqttMessage, subscribeToTopic, unsubscribeFromTopic } from '../../../plugins/mqtt';
|
|
9
|
-
import { TOPIC_DETAIL_CHAT, TOPIC_HOME } from '../../../constant/mqtt';
|
|
10
|
-
import { dataProfile } from '../../../utils/chat/auth';
|
|
11
|
-
import dayjs from 'dayjs';
|
|
12
|
-
import { DATE_FORMATS } from '../../../constant/datetime';
|
|
13
|
-
import { MessageState } from '../../../constant/message';
|
|
14
|
-
const props = withDefaults(defineProps(), {});
|
|
15
|
-
const emit = defineEmits();
|
|
16
|
-
let page = 1;
|
|
17
|
-
let pageCount = 1;
|
|
18
|
-
let topic = '';
|
|
19
|
-
const isLoading = ref(false);
|
|
20
|
-
const infoUser = shallowRef(null);
|
|
21
|
-
const listMessage = ref([]);
|
|
22
|
-
const chatMessageRef = ref(null);
|
|
23
|
-
onMounted(() => {
|
|
24
|
-
});
|
|
25
|
-
onUnmounted(() => {
|
|
26
|
-
handleDisconnectMqtt();
|
|
27
|
-
});
|
|
28
|
-
const handleConnectMqtt = async () => {
|
|
29
|
-
try {
|
|
30
|
-
await connectMqtt();
|
|
31
|
-
topic = TOPIC_DETAIL_CHAT + infoUser.value?.conversation_id;
|
|
32
|
-
subscribeToTopic(topic);
|
|
33
|
-
addHandleMqttMessage('chat-home', topic, mqttMessageHandler);
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.error(error);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const handleDisconnectMqtt = async () => {
|
|
40
|
-
const topic = TOPIC_DETAIL_CHAT + infoUser.value?.conversation_id;
|
|
41
|
-
unsubscribeFromTopic(topic);
|
|
42
|
-
removeHandleMqttMessage('chat-home');
|
|
43
|
-
};
|
|
44
|
-
const mqttMessageHandler = (topic, message) => {
|
|
45
|
-
if (infoUser.value?.id && message?.sender_id?.toString() == infoUser.value?.id?.toString() || true) {
|
|
46
|
-
const index = listMessage.value.findIndex((item) => item.id === message?.id);
|
|
47
|
-
if (index < 0) {
|
|
48
|
-
listMessage.value.push(message);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
listMessage.value[index] = message;
|
|
52
|
-
}
|
|
53
|
-
chatMessageRef.value?.scrollBottom();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const handleGetMessage = async () => {
|
|
57
|
-
try {
|
|
58
|
-
const id = props.receiverId;
|
|
59
|
-
const params = { page: page, receiver_id: props.receiverId };
|
|
60
|
-
let res = await getMessage(params);
|
|
61
|
-
res.items = res.items.reverse();
|
|
62
|
-
page = res._meta?.currentPage || 1;
|
|
63
|
-
pageCount = res._meta?.pageCount || 1;
|
|
64
|
-
if (id == props.receiverId)
|
|
65
|
-
listMessage.value.unshift(...res.items);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
console.error(error);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const handleScrollTop = async () => {
|
|
72
|
-
if (page >= pageCount) {
|
|
73
|
-
chatMessageRef.value?.hideScrollEvent();
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
page = page + 1;
|
|
77
|
-
await handleGetMessage();
|
|
78
|
-
chatMessageRef.value?.hideScrollEvent();
|
|
79
|
-
};
|
|
80
|
-
const handleGetDetailReceiver = async (data) => {
|
|
81
|
-
const id = props.receiverId;
|
|
82
|
-
if (data)
|
|
83
|
-
infoUser.value = data;
|
|
84
|
-
const res = (await getDetailReceiver(props.receiverId)) ?? null;
|
|
85
|
-
if (id == props.receiverId) {
|
|
86
|
-
infoUser.value = res;
|
|
87
|
-
await handleConnectMqtt();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const getData = async (data) => {
|
|
91
|
-
try {
|
|
92
|
-
isLoading.value = true;
|
|
93
|
-
listMessage.value = [];
|
|
94
|
-
await Promise.allSettled([handleGetMessage(), handleGetDetailReceiver(data)]);
|
|
95
|
-
// readMessages(infoUser.value?.conversation_id)
|
|
96
|
-
await nextTick();
|
|
97
|
-
chatMessageRef.value?.scrollBottom();
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
console.error(error);
|
|
101
|
-
}
|
|
102
|
-
finally {
|
|
103
|
-
isLoading.value = false;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const updateMessageItem = (id, data) => {
|
|
107
|
-
const index = listMessage.value.findIndex((e) => e.id == id);
|
|
108
|
-
if (index > -1) {
|
|
109
|
-
const item = listMessage.value[index];
|
|
110
|
-
listMessage.value[index] = { ...item, ...data };
|
|
111
|
-
console.log({ ...item, ...data });
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const handleSendMessage = async (data) => {
|
|
115
|
-
try {
|
|
116
|
-
listMessage.value.push({ ...data, state: MessageState.Sending });
|
|
117
|
-
publishMessage(topic, {
|
|
118
|
-
...data,
|
|
119
|
-
state: MessageState.Sending
|
|
120
|
-
});
|
|
121
|
-
let file_upload = [];
|
|
122
|
-
if (data?.attachments?.length) {
|
|
123
|
-
updateMessageItem(data.id, { state: MessageState.Uploading });
|
|
124
|
-
file_upload = await handleUploadImage(data?.attachments[0].file_local);
|
|
125
|
-
}
|
|
126
|
-
updateMessageItem(data.id, { state: MessageState.Sending });
|
|
127
|
-
chatMessageRef.value?.scrollBottom();
|
|
128
|
-
const formData = new FormData();
|
|
129
|
-
formData.append('message', data.message ?? '');
|
|
130
|
-
formData.append('receiver_id', infoUser.value?.id ?? '');
|
|
131
|
-
if (file_upload.length) {
|
|
132
|
-
formData.append('url', file_upload[0]?.url ?? '');
|
|
133
|
-
}
|
|
134
|
-
await sendMessage(formData);
|
|
135
|
-
publishMessage(topic, {
|
|
136
|
-
...data,
|
|
137
|
-
state: MessageState.Sent,
|
|
138
|
-
attachments: file_upload
|
|
139
|
-
? [
|
|
140
|
-
{
|
|
141
|
-
file_name: data.attachments[0]?.file_name ?? '',
|
|
142
|
-
file_path: file_upload[0]?.url ?? ''
|
|
143
|
-
}
|
|
144
|
-
]
|
|
145
|
-
: []
|
|
146
|
-
});
|
|
147
|
-
updateMessageItem(data.id, { state: MessageState.Sent });
|
|
148
|
-
publicTopicConversationUpdate(false, data?.message ?? '');
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
updateMessageItem(data.id, {
|
|
152
|
-
state: MessageState.Failed,
|
|
153
|
-
error: typeof error?.message == 'string' ? error.message : ''
|
|
154
|
-
});
|
|
155
|
-
console.log(error.message);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const handleUploadImage = async (file) => {
|
|
159
|
-
if (file == null || file == undefined)
|
|
160
|
-
return [];
|
|
161
|
-
if (file.size > 1 * 1024 * 1024) {
|
|
162
|
-
throw new Error('File size exceeds limit');
|
|
163
|
-
}
|
|
164
|
-
const formData = new FormData();
|
|
165
|
-
formData.append('file', file);
|
|
166
|
-
const res = await upLoadImage(formData);
|
|
167
|
-
return res;
|
|
168
|
-
};
|
|
169
|
-
const publicTopicConversationUpdate = async (isSendImg, message) => {
|
|
170
|
-
const res = await getCountUnread({
|
|
171
|
-
conversation_id: infoUser.value?.conversation_id ?? 0,
|
|
172
|
-
receiver_id: Number(infoUser.value?.id)
|
|
173
|
-
});
|
|
174
|
-
const current = dayjs().format(DATE_FORMATS['DATE_FORMAT_FULL']);
|
|
175
|
-
const dataMessageForReceiver = {
|
|
176
|
-
id: infoUser.value?.conversation_id ?? 0,
|
|
177
|
-
receiver_id: Number(dataProfile.value?.id ?? 0),
|
|
178
|
-
username: dataProfile.value?.username ?? '',
|
|
179
|
-
customer_phone: dataProfile.value?.phone ?? '',
|
|
180
|
-
avatar: dataProfile.value?.avatar ?? '',
|
|
181
|
-
last_message: isSendImg ? `${infoUser.value?.username} sent images` : message,
|
|
182
|
-
last_message_time: current,
|
|
183
|
-
created_at: current,
|
|
184
|
-
updated_at: current,
|
|
185
|
-
unread_count: (res?.unread_count ?? 0) + 1,
|
|
186
|
-
status: 1,
|
|
187
|
-
color: dataProfile.value?.color ?? ''
|
|
188
|
-
};
|
|
189
|
-
publishMessage(`${TOPIC_HOME[0] + Number(infoUser.value?.id)}`, JSON.stringify(dataMessageForReceiver));
|
|
190
|
-
const dataMessageMyself = {
|
|
191
|
-
id: infoUser.value?.conversation_id ?? 0,
|
|
192
|
-
receiver_id: Number(dataProfile.value?.id ?? 0),
|
|
193
|
-
username: infoUser.value?.username ?? '',
|
|
194
|
-
customer_phone: infoUser.value?.phone ?? '',
|
|
195
|
-
avatar: infoUser.value?.avatar ?? '',
|
|
196
|
-
last_message: isSendImg ? `${infoUser.value?.username} sent images` : message,
|
|
197
|
-
last_message_time: current,
|
|
198
|
-
created_at: current,
|
|
199
|
-
updated_at: current,
|
|
200
|
-
unread_count: 0,
|
|
201
|
-
status: 1,
|
|
202
|
-
color: infoUser.value?.color
|
|
203
|
-
};
|
|
204
|
-
publishMessage(`${TOPIC_HOME[0] + Number(dataProfile.value?.id)}`, JSON.stringify(dataMessageMyself));
|
|
205
|
-
};
|
|
206
|
-
const call = () => {
|
|
207
|
-
if (infoUser.value) {
|
|
208
|
-
emit('call', infoUser.value);
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
const __VLS_exposed = { getData };
|
|
212
|
-
defineExpose(__VLS_exposed);
|
|
213
|
-
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
|
214
|
-
const __VLS_defaults = {};
|
|
215
|
-
const __VLS_ctx = {
|
|
216
|
-
...{},
|
|
217
|
-
...{},
|
|
218
|
-
...{},
|
|
219
|
-
...{},
|
|
220
|
-
...{},
|
|
221
|
-
};
|
|
222
|
-
let __VLS_elements;
|
|
223
|
-
let __VLS_components;
|
|
224
|
-
let __VLS_directives;
|
|
225
|
-
__VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
|
|
226
|
-
...{ class: "h-full flex flex-col overflow-hidden" },
|
|
227
|
-
});
|
|
228
|
-
/** @type {[typeof HomeHeader, ]} */ ;
|
|
229
|
-
// @ts-ignore
|
|
230
|
-
const __VLS_0 = __VLS_asFunctionalComponent(HomeHeader, new HomeHeader({
|
|
231
|
-
...{ 'onCall': {} },
|
|
232
|
-
...{ class: "shrink-0" },
|
|
233
|
-
data: (__VLS_ctx.infoUser),
|
|
234
|
-
}));
|
|
235
|
-
const __VLS_1 = __VLS_0({
|
|
236
|
-
...{ 'onCall': {} },
|
|
237
|
-
...{ class: "shrink-0" },
|
|
238
|
-
data: (__VLS_ctx.infoUser),
|
|
239
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_0));
|
|
240
|
-
let __VLS_3;
|
|
241
|
-
let __VLS_4;
|
|
242
|
-
const __VLS_5 = ({ call: {} },
|
|
243
|
-
{ onCall: (__VLS_ctx.call) });
|
|
244
|
-
// @ts-ignore
|
|
245
|
-
[infoUser, call,];
|
|
246
|
-
var __VLS_2;
|
|
247
|
-
if (__VLS_ctx.listMessage?.length) {
|
|
248
|
-
// @ts-ignore
|
|
249
|
-
[listMessage,];
|
|
250
|
-
/** @type {[typeof ChatMessage, ]} */ ;
|
|
251
|
-
// @ts-ignore
|
|
252
|
-
const __VLS_7 = __VLS_asFunctionalComponent(ChatMessage, new ChatMessage({
|
|
253
|
-
...{ 'onScrollTop': {} },
|
|
254
|
-
ref: "chatMessageRef",
|
|
255
|
-
data: (__VLS_ctx.infoUser),
|
|
256
|
-
message: (__VLS_ctx.listMessage),
|
|
257
|
-
...{ class: "grow" },
|
|
258
|
-
response: (__VLS_ctx.response),
|
|
259
|
-
}));
|
|
260
|
-
const __VLS_8 = __VLS_7({
|
|
261
|
-
...{ 'onScrollTop': {} },
|
|
262
|
-
ref: "chatMessageRef",
|
|
263
|
-
data: (__VLS_ctx.infoUser),
|
|
264
|
-
message: (__VLS_ctx.listMessage),
|
|
265
|
-
...{ class: "grow" },
|
|
266
|
-
response: (__VLS_ctx.response),
|
|
267
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_7));
|
|
268
|
-
let __VLS_10;
|
|
269
|
-
let __VLS_11;
|
|
270
|
-
const __VLS_12 = ({ scrollTop: {} },
|
|
271
|
-
{ onScrollTop: (__VLS_ctx.handleScrollTop) });
|
|
272
|
-
/** @type {typeof __VLS_ctx.chatMessageRef} */ ;
|
|
273
|
-
var __VLS_13 = {};
|
|
274
|
-
// @ts-ignore
|
|
275
|
-
[infoUser, listMessage, response, handleScrollTop, chatMessageRef,];
|
|
276
|
-
var __VLS_9;
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
/** @type {[typeof NewCustomer, ]} */ ;
|
|
280
|
-
// @ts-ignore
|
|
281
|
-
const __VLS_16 = __VLS_asFunctionalComponent(NewCustomer, new NewCustomer({
|
|
282
|
-
data: (__VLS_ctx.infoUser),
|
|
283
|
-
...{ class: "grow" },
|
|
284
|
-
}));
|
|
285
|
-
const __VLS_17 = __VLS_16({
|
|
286
|
-
data: (__VLS_ctx.infoUser),
|
|
287
|
-
...{ class: "grow" },
|
|
288
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_16));
|
|
289
|
-
// @ts-ignore
|
|
290
|
-
[infoUser,];
|
|
291
|
-
}
|
|
292
|
-
/** @type {[typeof InputChat, ]} */ ;
|
|
293
|
-
// @ts-ignore
|
|
294
|
-
const __VLS_20 = __VLS_asFunctionalComponent(InputChat, new InputChat({
|
|
295
|
-
...{ 'onSendMessage': {} },
|
|
296
|
-
data: (__VLS_ctx.infoUser),
|
|
297
|
-
...{ class: "p-6" },
|
|
298
|
-
}));
|
|
299
|
-
const __VLS_21 = __VLS_20({
|
|
300
|
-
...{ 'onSendMessage': {} },
|
|
301
|
-
data: (__VLS_ctx.infoUser),
|
|
302
|
-
...{ class: "p-6" },
|
|
303
|
-
}, ...__VLS_functionalComponentArgsRest(__VLS_20));
|
|
304
|
-
let __VLS_23;
|
|
305
|
-
let __VLS_24;
|
|
306
|
-
const __VLS_25 = ({ sendMessage: {} },
|
|
307
|
-
{ onSendMessage: (__VLS_ctx.handleSendMessage) });
|
|
308
|
-
// @ts-ignore
|
|
309
|
-
[infoUser, handleSendMessage,];
|
|
310
|
-
var __VLS_22;
|
|
311
|
-
/** @type {__VLS_StyleScopedClasses['h-full']} */ ;
|
|
312
|
-
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
|
|
313
|
-
/** @type {__VLS_StyleScopedClasses['flex-col']} */ ;
|
|
314
|
-
/** @type {__VLS_StyleScopedClasses['overflow-hidden']} */ ;
|
|
315
|
-
/** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
|
|
316
|
-
/** @type {__VLS_StyleScopedClasses['grow']} */ ;
|
|
317
|
-
/** @type {__VLS_StyleScopedClasses['grow']} */ ;
|
|
318
|
-
/** @type {__VLS_StyleScopedClasses['p-6']} */ ;
|
|
319
|
-
// @ts-ignore
|
|
320
|
-
var __VLS_14 = __VLS_13;
|
|
321
|
-
const __VLS_export = (await import('vue')).defineComponent({
|
|
322
|
-
setup: () => (__VLS_exposed),
|
|
323
|
-
__typeEmits: {},
|
|
324
|
-
__typeProps: {},
|
|
325
|
-
props: {},
|
|
326
|
-
});
|
|
327
|
-
export default {};
|