-
-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loadingMessages fails to update even after setting messageLoaded (BUG) #40
Comments
I can reproduce this issue. I researched a bit and think it's happening because the messages watcher doesn't get triggered and therefor I couldn't find a quick fix for this problem. I try again later. @antoine92190 Maybe you have an idea? |
Can you try
If not working, maybe try a workaround below
@aubrydario @Minato-TW In any case, could you share a full working component with dummy data so I can reproduce the issue and find a clean solution? |
Please also make sure you are using the latest version of the |
I still have the same issue after trying your code above. Yes, I'm using the latest version from npm. Here's a minimum reproducible component. <template>
<chat-window
:currentUserId="currentUserId"
:rooms="rooms"
:messages="messages"
height="calc(100vh - 64px)"
class="mt-16 pa-5"
:loadingRooms="loadingRooms"
:messagesLoaded="messagesLoaded"
@fetchMessages="fetchMessages"
:showNewMessagesDivider="false"
:theme="theme"
/>
</template>
<script>
import ChatWindow from "vue-advanced-chat";
import "vue-advanced-chat/dist/vue-advanced-chat.css";
export default {
components: {
ChatWindow,
},
data() {
return {
rooms: [
{
roomId: "global",
roomName: "Global Chat",
users: [
{
_id: 1234,
username: "John Doe",
status: {
state: "online",
last_changed: "today, 14:30",
},
},
{
_id: 4321,
username: "John Snow",
status: {
state: "online",
last_changed: "14 July, 20:00",
},
},
],
},
{
roomId: "private",
roomName: "Private Chat",
users: [
{
_id: 1234,
username: "John Doe",
status: {
state: "online",
last_changed: "today, 14:30",
},
},
{
_id: 4321,
username: "John Snow",
status: {
state: "online",
last_changed: "14 July, 20:00",
},
},
],
},
],
allMessages: [
{
_id: 7890,
content: "message 1",
roomId: "global",
sender_id: 1234,
username: "John Doe",
date: "13 November",
timestamp: "10:10",
seen: true,
},
{
_id: 3333,
content: "message 2",
roomId: "private",
sender_id: 1234,
username: "John Doe",
date: "13 November",
timestamp: "10:20",
seen: true,
},
{
_id: 5555,
content: "message 2",
roomId: "global",
sender_id: 4321,
username: "John Snow",
date: "14 November",
timestamp: "10:22",
seen: true,
},
],
currentUserId: 1234,
loadingRooms: false,
messagesLoaded: true,
messages: [],
selectedRoom: null,
theme: "dark",
};
},
methods: {
fetchMessages: function ({ room, options }) {
this.selectedRoom = room.roomId;
this.messages = this.allMessages.filter(
(message) => message.roomId === this.selectedRoom
);
console.log(this.messages);
},
},
};
</script>
<style>
.chat-container {
box-shadow: 0 0 4px rgb(88, 84, 84);
border-radius: 0px !important;
}
</style> As soon as I click on the private room and go back to Global, the infinite spinner starts. Thank you. |
Thanks, I can reproduce the issue. I will fix this very soon |
Fixed in 9d0a7ef |
Thanks for fixing this so quickly! |
Hello, I still seem to have the issue when one or both of the rooms have 0 messages. You can use the same code from above just with the "private" room message removed. allMessages: [
{
_id: 7890,
content: "message 1",
roomId: "global",
sender_id: 1234,
username: "John Doe",
date: "13 November",
timestamp: "10:10",
seen: true,
},
{
_id: 5555,
content: "message 2",
roomId: "global",
sender_id: 4321,
username: "John Snow",
date: "14 November",
timestamp: "10:22",
seen: true,
},
] Clicking on the private chat runs an infinite spinner instead of showing "No messages". Thank you. |
This happens because you are playing with hardcoded data.
|
Thanks, that was it. |
Describe the bug
After switching to a new room to fetch messages, the
loadingMessages
variable fails to update resulting in infinite spinner.Steps to reproduce
The following snippet from my code filters messages based on the selected room and sets the
messagesLoaded
prop.Expected behavior
A clear and concise description of what you expected to happen when you encounter the bug.
Screenshots
As seen in the image above,
messagesLoaded
is set totrue
but the spinner continues running. Not sure if I'm missing something obvious here.Device (please complete the following information)
Thank you!
The text was updated successfully, but these errors were encountered: