@bcc-code/vue-bcc-chat-ui 1.0.8 → 1.1.1

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": "1.0.8",
5
+ "version": "1.1.1",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -13,17 +13,8 @@
13
13
  "type": "git",
14
14
  "url": "git+https://github.com/bcc-code/bcc-chat.git"
15
15
  },
16
- "main": "./dist/vue-bcc-chat-ui.umd.cjs",
17
16
  "module": "./dist/vue-bcc-chat-ui.js",
18
17
  "types": "./dist/index.d.ts",
19
- "exports": {
20
- ".": {
21
- "import": "./dist/vue-bcc-chat-ui.js",
22
- "types": "./dist/index.d.ts",
23
- "require": "./dist/vue-bcc-chat-ui.umd.cjs"
24
- },
25
- "./style.css": "./dist/style.css"
26
- },
27
18
  "publishConfig": {
28
19
  "access": "public"
29
20
  },
@@ -38,18 +29,17 @@
38
29
  "vite": "^5.0.8",
39
30
  "vite-plugin-dts": "^3.7.2",
40
31
  "vue": "^3.3.11",
41
- "vue-tsc": "^1.8.25"
32
+ "sass": "^1.70.0"
42
33
  },
43
34
  "dependencies": {
44
35
  "@cometchat/chat-sdk-javascript": "^4.0.3",
45
36
  "@cometchat/chat-uikit-vue": "^4.2.0",
46
37
  "@cometchat/uikit-resources": "^4.2.2",
47
- "@cometchat/uikit-shared": "^4.2.1",
48
- "sass": "^1.70.0"
38
+ "@cometchat/uikit-shared": "^4.2.1"
49
39
  },
50
40
  "scripts": {
51
41
  "dev": "vite",
52
- "build": "vite build && vue-tsc --emitDeclarationOnly",
42
+ "build": "vite build",
53
43
  "preview": "vite preview"
54
44
  }
55
45
  }
@@ -1,69 +1,55 @@
1
1
  <script setup lang="ts">
2
- import { computed, onBeforeMount, ref } from 'vue'
2
+ import { onBeforeMount, onUnmounted, ref } from 'vue'
3
3
  import chat from '../chat';
4
- import { watch } from 'vue';
5
4
  import { CometChatMessages } from '@cometchat/chat-uikit-vue'
5
+ import { Group } from '@cometchat/chat-sdk-javascript';
6
+ import { watch } from 'vue';
6
7
  //import { ThreadedMessagesStyle } from '@cometchat/uikit-shared';
7
8
 
8
9
  const props = defineProps({
9
- accessToken: String,
10
- chatUid: String,
11
- active: Boolean
10
+ chatUid: {type: String, required: true},
12
11
  })
13
12
 
14
- const accessToken = computed(() => props.accessToken);
15
- const active = computed(() => props.active);
16
- const connected = ref(false);
17
- const chatGroup = ref();
18
- const user = ref();
19
-
20
-
21
- const connect = async () => {
22
- if (accessToken.value && active.value){
23
- user.value = await chat.connection.connect(accessToken.value);
24
- console.log('USER', user.value);
25
- if (props.chatUid){
26
- chatGroup.value = await chat.data.getGroup(props.chatUid);
27
- console.log('GROUP', chatGroup.value);
28
- }
29
- connected.value = true;
30
- }
31
- }
32
-
33
- const disconnect = async () => {
34
- console.log('Disconnecting');
35
- if (connected.value){
36
- await chat.connection.disconnect();
37
- console.log('Disconnected');
38
- connected.value = false;
39
- }
40
- }
13
+ const componentId = ref(`component-${Math.random().toString(36).substring(2, 11)}`);
14
+ const chatGroup = ref<Group>();
41
15
 
42
- watch(accessToken, async (token) => {
43
- if (token && active){
44
- await connect();
45
- }
16
+ onBeforeMount(async() => {
17
+ await connnect();
18
+ await loadData();
46
19
  });
47
20
 
48
- watch(active, async (isActive, wasActive) => {
49
- if (isActive && !wasActive){
50
- await connect();
51
- }
52
- if (!isActive && connected.value){
53
- await disconnect();
54
- }
21
+ watch(chat.connection.connected, async () => {
22
+ await loadData();
55
23
  });
56
24
 
57
- onBeforeMount(async() => {
58
- await connect();
25
+ onUnmounted(async () => {
26
+ await disconnect();
59
27
  });
60
28
 
29
+ // Disconnects from chat server
30
+ const disconnect = async () => {
31
+ await chat.connection.disconnect(componentId.value);
32
+ };
33
+
34
+ // Connect to chat server
35
+ const connnect = async() => {
36
+ await chat.connection.connect(componentId.value);
37
+ };
38
+
39
+ // Loads data if chat is connected
40
+ const loadData = async () => {
41
+ if (chat.connection.connected.value && props.chatUid) {
42
+ chatGroup.value = await chat.data.getGroup(props.chatUid);
43
+ } else {
44
+ chatGroup.value = undefined;
45
+ }
46
+ };
61
47
 
62
48
  </script>
63
49
 
64
50
  <template>
65
- <div v-if="connected" class="bcc-chat-message-list">
66
- <CometChatMessages :hideMessageHeader="true" :hideMessageComposer="false" :hideDetails="true" :group="chatGroup"></CometChatMessages>
51
+ <div v-if="chatGroup" class="bcc-chat-message-list">
52
+ <CometChatMessages :hideMessageHeader="true" :hideMessageComposer="false" :hideDetails="true" :group="chatGroup"></CometChatMessages>
67
53
  </div>
68
54
  </template>
69
55
 
@@ -71,49 +57,18 @@ onBeforeMount(async() => {
71
57
 
72
58
  .bcc-chat-message-list {
73
59
  height: 100%;
74
-
75
60
  /* 1. Wrapper for Messages component */
76
61
  .cc-messages-wrapper {
77
-
78
62
  /* 1.1 Messages component */
79
63
  .cc-messages-wrapper__messages {
80
-
81
64
  /* 1.1.1 Wrapper for Messages List */
82
65
  .cc-messages-wrapper__messages-list {
83
-
84
66
  height: calc(100% - 96px);
85
-
86
- /* 1.1.1.1 Messages List header view */
87
- .cc__messagelist__headerview {
88
- }
89
-
90
- /* 1.1.1.2 Messages List messages */
91
- .cc-messagelist {
92
- .cc-list__wrapper {
93
- .cc-list__header {
94
- }
95
- .cc-list__list {
96
- }
97
- }
98
- }
99
-
100
- /* 1.1.1.3 Message List footer */
101
- .cc__messagelist__footerview {
102
- }
103
67
  }
104
-
105
- /* 1.1.2 Wrapper for Composer */
106
- .cc-messages-wrapper__composer {
107
- }
108
-
109
- /* 1.1.3 Wrapper for Live Reaction */
110
- .cc__messages__livereaction {
111
- }
112
-
113
68
  }
114
-
115
69
  }
116
70
  }
71
+
117
72
  .cc-threadedmessages-wrapper__bubbleview::-webkit-scrollbar,
118
73
  .cc__message-list::-webkit-scrollbar {
119
74
  background: transparent;
@@ -126,5 +81,4 @@ onBeforeMount(async() => {
126
81
  border-radius: 8px;
127
82
  }
128
83
 
129
-
130
84
  </style>
package/dist/App.vue.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
- export default _default;