Skip to content

Commit a623323

Browse files
committed
(fix) show rooms when last messages are loaded
1 parent 9d74b30 commit a623323

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

demo/src/ChatContainer.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
:theme="theme"
5151
:styles="styles"
5252
:current-user-id="currentUserId"
53-
:rooms="loadingRooms ? [] : rooms"
53+
:rooms="loadedRooms"
5454
:loading-rooms="loadingRooms"
5555
:messages="messages"
5656
:messages-loaded="messagesLoaded"
@@ -104,6 +104,7 @@ export default {
104104
loadingRooms: true,
105105
allUsers: [],
106106
loadingLastMessageByRoom: 0,
107+
roomsLoadedCount: false,
107108
selectedRoom: null,
108109
messagesPerPage: 20,
109110
messages: [],
@@ -141,10 +142,17 @@ export default {
141142
this.resetRooms()
142143
},
143144
145+
computed: {
146+
loadedRooms() {
147+
return this.rooms.slice(0, this.roomsLoadedCount)
148+
}
149+
},
150+
144151
methods: {
145152
resetRooms() {
146153
this.loadingRooms = true
147154
this.loadingLastMessageByRoom = 0
155+
this.roomsLoadedCount = 0
148156
this.rooms = []
149157
this.roomsLoaded = false
150158
this.startRooms = null
@@ -248,7 +256,10 @@ export default {
248256
this.rooms = this.rooms.concat(formattedRooms)
249257
formattedRooms.map(room => this.listenLastMessage(room))
250258
251-
if (!this.rooms.length) this.loadingRooms = false
259+
if (!this.rooms.length) {
260+
this.loadingRooms = false
261+
this.roomsLoadedCount = 0
262+
}
252263
253264
this.listenUsersOnlineStatus(formattedRooms)
254265
this.listenRoomsTypingUsers(query)
@@ -274,6 +285,7 @@ export default {
274285
275286
if (this.loadingLastMessageByRoom === this.rooms.length) {
276287
this.loadingRooms = false
288+
this.roomsLoadedCount = this.rooms.length
277289
}
278290
}
279291
})

0 commit comments

Comments
 (0)