@bcc-code/vue-bcc-chat-ui 3.34.0 → 3.37.0

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@bcc-code/vue-bcc-chat-ui",
3
3
  "author": "bcc-code",
4
4
  "license": "Apache-2.0",
5
- "version": "3.34.0",
5
+ "version": "3.37.0",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -40,6 +40,7 @@ const chatInstance: Ref<ChatInstance> = ref({
40
40
  decoyAttachment: null,
41
41
  showScheduledMessagesChat: false,
42
42
  showAlert: false,
43
+ showRescheduleAlert: false,
43
44
  userInput: null,
44
45
  rescheduleInfo: null
45
46
  });
@@ -1,16 +1,12 @@
1
1
  <script setup lang="ts">
2
2
  import chat from "../chat";
3
3
  import { Group } from "@cometchat/chat-sdk-javascript";
4
- import { inject, nextTick, onMounted, onUnmounted, Ref, ref, watch, watchEffect } from 'vue';
5
- import { sendScheduledMessage } from '../chat/scheduledMessage';
4
+ import { inject, nextTick, onMounted, Ref, ref, watch, watchEffect } from 'vue';
6
5
  import { ChatInstance } from '../chat/types';
7
6
  import BccAttachmentBox from "./BccAttachmentBox.vue";
8
7
  import BccChatSendButton from "./BccChatSendButton.vue";
9
8
  import { getMessageComposerConfiguration, getMessageListConfiguration, getThreadedMessagesConfiguration } from "../chat/uiKit";
10
9
  import { CometChatMessages } from "../chat/cometChatPatches";
11
- import BccScheduledMessageModal from "./BccScheduledMessageModal.vue";
12
- import { BccAlert } from "@bcc-code/design-library-vue";
13
- import { localize } from "@cometchat/uikit-resources";
14
10
  import { MessageComposerConfiguration } from "@cometchat/uikit-shared";
15
11
 
16
12
  const props = defineProps({
@@ -30,11 +26,9 @@ onMounted(async () => {
30
26
  chatGroup.value = props.chatGroup
31
27
  // attachEventlisteners();
32
28
 
29
+ messageComposerConfiguration.value.text = chatInstance?.value.userInput ?? '';
30
+
33
31
  await nextTick();
34
- const userInput = document.querySelector('.messageinput-input');
35
- if (userInput && chatInstance?.value.userInput) {
36
- userInput.innerHTML = chatInstance.value.userInput;
37
- }
38
32
  if (chatInstance?.value.decoyAttachment) {
39
33
  chatInstance.value.captionedAttachment = chatInstance.value.decoyAttachment
40
34
  chatInstance.value.decoyAttachment = null
@@ -4,7 +4,13 @@ import { localize } from '@cometchat/uikit-resources';
4
4
  import { computed, onMounted, ref } from 'vue';
5
5
  import "../style.css";
6
6
 
7
- const emit = defineEmits(['close', 'send']);
7
+ const props = defineProps({
8
+ isReschedule: { type: Boolean, default: false }
9
+ })
10
+
11
+ const title = props.isReschedule ? localize("RESCHEDULE") : localize("SCHEDULE_MESSAGE")
12
+
13
+ const emit = defineEmits(['close', 'schedule', 'reschedule']);
8
14
 
9
15
  const dateInput = ref<string>();
10
16
  const timeInput = ref<string>();
@@ -14,8 +20,6 @@ const localDateTime = computed<string>(() => {
14
20
  return new Date(dateInput.value + "T" + timeInput.value).toISOString()
15
21
  })
16
22
 
17
- const title = ref(localize("SCHEDULE_MESSAGE"));
18
-
19
23
  const isDateInFuture = computed<boolean>(() => {
20
24
  if (dateInput.value === '' || timeInput.value === '') return false
21
25
  return new Date(localDateTime.value) > new Date();
@@ -37,14 +41,14 @@ function close() {
37
41
 
38
42
  function scheduleMessage() {
39
43
  if (isDateInFuture && !messageSent.value) {
40
- emit('send', localDateTime.value)
44
+ emit(props.isReschedule ? 'reschedule' : 'schedule', localDateTime.value)
41
45
  messageSent.value = true;
42
46
  }
43
47
  }
44
48
  </script>
45
49
 
46
50
  <template>
47
- <BccModal class="modal" :title=title :open="true" @close="close()" :closeButton="true">
51
+ <BccModal class="modal" :title="title" :open="true" @close="close()" :closeButton="true">
48
52
  <div class="flex flex-col w-full">
49
53
  <div class="flex flex-row w-full justify-between">
50
54
  <input class="input" type="date" v-model="dateInput" required>
@@ -65,6 +65,7 @@ onUnmounted(() => {
65
65
  chatInstance.value.scheduledMessageChat = undefined
66
66
  chatInstance.value.showScheduledMessagesChat = false
67
67
  chatInstance.value.showAlert = false
68
+ chatInstance.value.rescheduleInfo = null
68
69
  }
69
70
  })
70
71
 
@@ -90,6 +91,10 @@ onUnmounted(() => {
90
91
  :open="chatInstance!.showAlert" @close="chatInstance!.showAlert = false">
91
92
  {{ localize("ERROR_SENDING_SCHEDULED_MESSAGE") }}
92
93
  </BccAlert>
94
+ <BccAlert class="absolute top-0 w-[97%] mx-2 mt-11" icon closeButton context="danger"
95
+ :open="chatInstance!.showRescheduleAlert" @close="chatInstance!.showRescheduleAlert = false">
96
+ {{ localize("ERROR_RESCHEDULING_MESSAGE") }}
97
+ </BccAlert>
93
98
  </div>
94
99
  </div>
95
100
  </template>
@@ -10,6 +10,8 @@ const props = defineProps({
10
10
  chatUid: { type: String, required: true }
11
11
  })
12
12
 
13
+ const isReschedule = ref<boolean>(false);
14
+
13
15
  const chatInstance = inject<Ref<ChatInstance>>("chatInstance");
14
16
  const vueInstance: any = getCurrentInstance();
15
17
  const msgComposerData = vueInstance?.parent?.type?.name === "CometChatMessageComposer" && vueInstance?.parent?.setupState;
@@ -53,8 +55,10 @@ onBeforeUnmount(() => {
53
55
 
54
56
  watchEffect(async () => {
55
57
  if (chatInstance && chatInstance.value.rescheduleInfo) {
58
+ isReschedule.value = true;
56
59
  showModal.value = true;
57
60
  } else {
61
+ isReschedule.value = false;
58
62
  showModal.value = false;
59
63
  }
60
64
  })
@@ -74,22 +78,32 @@ function closeModal() {
74
78
 
75
79
  function scheduleMessage(scheduleDate?: string) {
76
80
  if (scheduleDate && chatInstance) {
77
- if (chatInstance.value.rescheduleInfo) {
78
- rescheduleMessage(scheduleDate, props.chatUid, chatInstance.value.rescheduleInfo.rescheduleMuid, chatInstance.value.rescheduleInfo.messageId)
79
- } else {
80
- sendScheduledMessage(scheduleDate, props.chatUid, chatInstance).then((msgSuccessful) => {
81
- if (!msgSuccessful) {
82
- showModal.value = false
83
- chatInstance.value.showAlert = true
84
- setTimeout(() => chatInstance.value.showAlert = false, 5000)
85
- } else {
86
- showModal.value = false
87
- msgComposerData.messageText = "";
88
- msgComposerData.textRef = "";
89
- msgComposerData.inputRef?.emptyInputField();
90
- }
91
- });
92
- }
81
+ sendScheduledMessage(scheduleDate, props.chatUid, chatInstance).then((msgSuccessful) => {
82
+ if (!msgSuccessful) {
83
+ showModal.value = false
84
+ chatInstance.value.showAlert = true
85
+ setTimeout(() => chatInstance.value.showAlert = false, 5000)
86
+ } else {
87
+ showModal.value = false
88
+ msgComposerData.messageText = "";
89
+ msgComposerData.textRef = "";
90
+ msgComposerData.inputRef?.emptyInputField();
91
+ }
92
+ });
93
+ }
94
+ }
95
+
96
+ function reschedule(scheduleDate?: string) {
97
+ if (scheduleDate && chatInstance && chatInstance.value.rescheduleInfo) {
98
+ rescheduleMessage(scheduleDate, props.chatUid, chatInstance.value.rescheduleInfo.rescheduleMuid, chatInstance.value.rescheduleInfo.messageId).then((successful) => {
99
+ if (!successful) {
100
+ showModal.value = false
101
+ chatInstance.value.showRescheduleAlert = true
102
+ setTimeout(() => chatInstance.value.showRescheduleAlert = false, 5000)
103
+ } else {
104
+ showModal.value = false
105
+ }
106
+ })
93
107
  }
94
108
  }
95
109
  </script>
@@ -99,5 +113,6 @@ function scheduleMessage(scheduleDate?: string) {
99
113
  <cometchat-button :iconURL="sendButtonIconURL" :buttonStyle="sendButtonStyle"
100
114
  :hoverText="localize('SCHEDULE_MESSAGE')" @click="sendMessage()" />
101
115
  </div>
102
- <BccScheduledMessageModal v-if="showModal" @close="closeModal()" @send="scheduleMessage"></BccScheduledMessageModal>
116
+ <BccScheduledMessageModal v-if="showModal" @close="closeModal()" @schedule="scheduleMessage" @reschedule="reschedule" :isReschedule="isReschedule">
117
+ </BccScheduledMessageModal>
103
118
  </template>