Skip to content

Commit 2073bef

Browse files
Update Sample to version 4.3.8
1 parent 8bb9d89 commit 2073bef

File tree

4 files changed

+64
-32
lines changed

4 files changed

+64
-32
lines changed

src/Login/index.vue

+28-31
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<script lang="ts">
120120
/*es-lint disabled*/
121121
122-
import { defineComponent, inject, ref } from "vue";
122+
import { defineComponent, inject, onBeforeMount, ref } from "vue";
123123
import "@cometchat/uikit-elements";
124124
import { fontHelper } from "@cometchat/uikit-resources";
125125
import { CometChat } from "@cometchat/chat-sdk-javascript";
@@ -133,8 +133,15 @@ import {
133133
} from "../assets";
134134
import { CometChatUIKit } from "@cometchat/chat-uikit-vue";
135135
import { metaInfo } from "../metaInfo";
136+
import { users } from "../sampleApp/sampledata";
136137
let buttonImage = "assets/button-opc.png";
137138
139+
type User = {
140+
name: string;
141+
uid: string;
142+
avatar: string;
143+
};
144+
138145
export default defineComponent({
139146
name: "LoginComponent",
140147
components: {},
@@ -148,6 +155,7 @@ export default defineComponent({
148155
let enteredUid!: string;
149156
let enteredName!: string;
150157
let inProgress = ref(false);
158+
const usersArray = ref<User[]>([]);
151159
152160
let avatarStyle: AvatarStyle = {
153161
height: "32px",
@@ -236,36 +244,25 @@ export default defineComponent({
236244
router.push({ path: "/signup" });
237245
};
238246
239-
const usersArray = [
240-
{
241-
name: "Iron Man",
242-
UID: "SUPERHERO1",
243-
uid: "superhero1",
244-
avatar:
245-
"https://data-us.cometchat.io/assets/images/avatars/ironman.png",
246-
},
247-
{
248-
name: "Captain America",
249-
UID: "SUPERHERO2",
250-
uid: "superhero2",
251-
avatar:
252-
"https://data-us.cometchat.io/assets/images/avatars/captainamerica.png",
253-
},
254-
{
255-
name: "Spiderman",
256-
UID: "SUPERHERO3",
257-
uid: "superhero3",
258-
avatar:
259-
"https://data-us.cometchat.io/assets/images/avatars/spiderman.png",
260-
},
261-
{
262-
name: "Wolvorine",
263-
UID: "SUPERHERO4",
264-
uid: "superhero4",
265-
avatar:
266-
"https://data-us.cometchat.io/assets/images/avatars/wolverine.png",
267-
},
268-
];
247+
async function fetchDefaultUsers() {
248+
try {
249+
const response = await fetch(
250+
"https://assets.cometchat.io/sampleapp/sampledata.json"
251+
);
252+
const data = await response.json();
253+
usersArray.value = data.users;
254+
} catch (error) {
255+
console.log(
256+
"fetching default users failed, using fallback data",
257+
error
258+
);
259+
usersArray.value = users.users;
260+
}
261+
}
262+
263+
onBeforeMount(() => {
264+
fetchDefaultUsers();
265+
});
269266
270267
const styles: any = {
271268
loginWrapperStyle: () => {

src/assets/wolverine_avatar.png

9.75 KB
Loading

src/metaInfo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const metaInfo = {
22
name: "cometchat-chat-sample-app-vue",
3-
version: "4.3.7",
3+
version: "4.3.8",
44
type: "sample",
55
platform: "Vue",
66
};

src/sampleApp/sampledata.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import CaptainAmericaAvatar from "../assets/captainamerica_avatar.png";
2+
import CyclopsAvatar from "../assets/cyclops_avatar.png";
3+
import IronManAvatar from "../assets/ironman_avatar.png";
4+
import SpidermanAvatar from "../assets/spiderman_avatar.png";
5+
import WolverineAvatar from "../assets/wolverine_avatar.png";
6+
7+
export const users = {
8+
users: [
9+
{
10+
uid: "superhero1",
11+
name: "Iron Man",
12+
avatar: IronManAvatar,
13+
},
14+
{
15+
uid: "superhero2",
16+
name: "Captain America",
17+
avatar: CaptainAmericaAvatar,
18+
},
19+
{
20+
uid: "superhero3",
21+
name: "Spiderman",
22+
avatar: SpidermanAvatar,
23+
},
24+
{
25+
uid: "superhero4",
26+
name: "Wolverine",
27+
avatar: WolverineAvatar,
28+
},
29+
{
30+
uid: "superhero5",
31+
name: "Cyclops",
32+
avatar: CyclopsAvatar,
33+
},
34+
],
35+
};

0 commit comments

Comments
 (0)