Skip to content

Commit fef0488

Browse files
committed
(fix) rooms sorting
1 parent 8606e13 commit fef0488

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/ChatWindow/ChatWindow.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,10 @@ export default {
169169
},
170170
orderedRooms() {
171171
return this.rooms.slice().sort((a, b) => {
172-
if (!a.lastMessage || !b.lastMessage) return 0
172+
const aVal = a.lastMessage || { date: 0 }
173+
const bVal = b.lastMessage || { date: 0 }
173174
174-
return a.lastMessage.date > b.lastMessage.date
175-
? -1
176-
: b.lastMessage.date > a.lastMessage.date
177-
? 1
178-
: 0
175+
return aVal.date > bVal.date ? -1 : bVal.date > aVal.date ? 1 : 0
179176
})
180177
}
181178
},

0 commit comments

Comments
 (0)