Comments (6)
Indeed, the chat is not working properly without managing the loading pattern of rooms and messages.
loadingRooms
and messagesLoaded
need to be initialised properly, and then reassigned. Please try snippet below:
<template>
<chat-window
:currentUserId="1234"
:rooms="rooms"
:loadingRooms="loadingRooms"
:messages="messages"
:messagesLoaded="messagesLoaded"
>
</chat-window>
</template>
<script>
import ChatWindow from 'vue-advanced-chat'
import 'vue-advanced-chat/dist/vue-advanced-chat.css'
export default {
components: {
ChatWindow
},
data() {
return {
rooms: [],
loadingRooms: true,
messages: [],
messagesLoaded: false
}
},
mounted() {
this.rooms = [
{
roomId: 1,
roomName: 'Room 1',
unreadCount: 4,
lastMessage: {
content: 'Last message received',
sender_id: 1234,
username: 'John Doe',
timestamp: '10:20',
date: 123242424,
seen: false,
new: true
},
users: [
{
_id: 1234,
username: 'John Doe',
status: {
state: 'online',
last_changed: 'today, 14:30'
}
},
{
_id: 4321,
username: 'John Snow',
status: {
state: 'offline',
last_changed: '14 July, 20:00'
}
}
],
typingUsers: [4321]
}
]
this.messages = [
{
_id: 12345,
roomId: 1,
content: 'Heeeey',
sender_id: 4321,
username: 'Tu',
date: '13 November',
timestamp: '10:20',
seen: true,
disable_actions: false,
disable_reactions: true
}
]
this.loadingRooms = false
this.messagesLoaded = true
}
}
</script>
from vue-advanced-chat.
Issue should be fixed in 1509e5e
There is no need to follow the loading pattern described above anymore.
from vue-advanced-chat.
The below component works fine for me. Can you try and let me know if it works on you side. If not is there any error in the console?
<template>
<chat-window
:currentUserId="1234"
:rooms="[
{
roomId: 1,
roomName: 'Tu',
unreadCount: 4,
lastMessage: {
content: 'Heeeeyooooo!!',
sender_id: 4321,
username: 'John snow',
timestamp: '10:20',
date: 123242424,
seen: false,
new: true
},
users: [
{
_id: 1234,
username: 'John snow',
status: {
state: 'online',
last_changed: 'today, 14:30'
}
},
{
_id: 4321,
username: 'Ingrid',
status: {
state: 'offline',
last_changed: '14 July, 20:00'
}
}
]
}
]"
:messages="[
{
_id: 12345,
roomId: 1,
content: 'Heeeey',
sender_id: 4321,
username: 'Tu',
date: '13 November',
timestamp: '10:20',
seen: true,
disable_actions: false,
disable_reactions: true
}
]"
:messagesLoaded="true"
>
</chat-window>
</template>
<script>
import ChatWindow from 'vue-advanced-chat'
import 'vue-advanced-chat/dist/vue-advanced-chat.css'
export default {
components: {
ChatWindow
}
}
</script>
from vue-advanced-chat.
Hi, I just tried, and the message appears outside the room
When I click in the room I get this
No errors in the console
from vue-advanced-chat.
Thank you so much :)
I think it would be interesting to add this information in the readme
from vue-advanced-chat.
Yes definitely, I'll leave this issue open until then.
from vue-advanced-chat.
Related Issues (20)
- event fetch-more-rooms not working HOT 1
- room without message HOT 1
- templatesText bug: Input "/help" not working
- Spinner still there even when setting messages-loaded to true HOT 1
- Can you release a new version
- Will you release a new version HOT 2
- URGENT ** 2.0.8 NPMJS Package Missing Files | Broken HOT 2
- How to send a message with a file
- vue-tsc --noEmit && vite build fails
- Cannot read properties of undefined (reading 'roomId') HOT 1
- Editing a message to include a reply emits `send-message` instead
- Room message search
- Room list as slot does not update order after sorting?
- How to run locally for development HOT 1
- How can I return to the initial option when closing a room? Example room_empty = true
- In mobile mode, when a new message comes in, how to do it without returning to the roomlist HOT 2
- warning "vue-advanced-chat > [email protected]" has unmet peer dependency
- Not able to apply styles to the vac-progress-bar
- Named Slots not working with vue 3 HOT 1
- Show User is Typing Above Text Area Input HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-advanced-chat.