Skip to content

Commit f97f144

Browse files
committed
Vue updates
1 parent a58d02c commit f97f144

File tree

1 file changed

+29
-30
lines changed
  • vue/vue-getting-started/src/components

1 file changed

+29
-30
lines changed

vue/vue-getting-started/src/components/Chat.vue

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,42 @@
22

33
<template>
44
<div id="talkjs-container" style="width: 100%; height: 500px">
5-
<i>Loading chat...</i>
5+
<i>Loading chat...</i>
66
</div>
77
</template>
88

99
<script setup>
10-
import Talk from "talkjs";
11-
import { onMounted } from 'vue';
10+
import Talk from "talkjs";
11+
import { onMounted } from "vue";
1212
13-
onMounted(() => {
14-
Talk.ready.then(() => {
15-
const me = new Talk.User({
16-
id: 'nina',
17-
name: 'Nina',
18-
email: 'nina@example.com',
19-
photoUrl: 'https://talkjs.com/new-web/avatar-7.jpg',
20-
welcomeMessage: 'Hi!',
21-
});
22-
const session = new Talk.Session({
23-
appId: '<APP_ID>',
24-
me: me,
25-
});
13+
onMounted(() => {
14+
Talk.ready.then(() => {
15+
const session = new Talk.Session({
16+
appId: "<APP_ID>",
17+
userId: "nina",
18+
});
19+
session.currentUser.createIfNotExists({
20+
name: "Nina",
21+
email: "nina@example.com",
22+
photoUrl: "https://talkjs.com/new-web/avatar-7.jpg",
23+
welcomeMessage: "Hi!",
24+
});
2625
27-
const other = new Talk.User({
28-
id: 'frank',
29-
name: 'Frank',
30-
email: 'frank@example.com',
31-
photoUrl: 'https://talkjs.com/new-web/avatar-8.jpg',
32-
welcomeMessage: 'Hey, how can I help?',
33-
});
26+
const otherRef = session.user("frank");
27+
otherRef.createIfNotExists({
28+
name: "Frank",
29+
email: "frank@example.com",
30+
photoUrl: "https://talkjs.com/new-web/avatar-8.jpg",
31+
welcomeMessage: "Hey, how can I help?",
32+
});
3433
35-
const conversation = session.getOrCreateConversation('new_conversation');
36-
conversation.setParticipant(me);
37-
conversation.setParticipant(other);
34+
const conversationRef = session.conversation("new_conversation");
35+
conversationRef.createIfNotExists();
36+
conversationRef.participant(otherRef).createIfNotExists();
3837
39-
const chatbox = session.createChatbox();
40-
chatbox.select(conversation);
41-
chatbox.mount(document.getElementById('talkjs-container'));
42-
});
38+
const chatbox = session.createChatbox();
39+
chatbox.select(conversationRef);
40+
chatbox.mount(document.getElementById("talkjs-container"));
4341
});
42+
});
4443
</script>

0 commit comments

Comments
 (0)