Skip to content

Commit 801a284

Browse files
committed
(breaking) use index to sort rooms
1 parent 1adc8da commit 801a284

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,12 @@ rooms="[
468468
roomName: 'Room 1',
469469
avatar: 'assets/imgs/people.png',
470470
unreadCount: 4,
471+
index: 3,
471472
lastMessage: {
472473
content: 'Last message received',
473474
sender_id: 1234,
474475
username: 'John Doe',
475476
timestamp: '10:20',
476-
date: 123242424,
477477
saved: true,
478478
distributed: false,
479479
seen: false,
@@ -504,8 +504,8 @@ rooms="[
504504
]"
505505
```
506506

507-
- If you set a `date` to `lastMessage` property, your rooms will be ordered using this date value.
508-
`date` can be any sortable value, like a `string`, `datetime`, `timestamp`, etc.
507+
- If you add the `index` property, your rooms will be ordered using this value.
508+
`index` can be any sortable value, like a `string`, `datetime`, `timestamp`, etc.
509509

510510
- For each room user, you can add the `status` property, which can hold the `state` and `last_changed` properties:
511511

src/ChatWindow/ChatWindow.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ export default {
226226
},
227227
orderedRooms() {
228228
return this.rooms.slice().sort((a, b) => {
229-
const aVal = a.lastMessage || { date: 0 }
230-
const bVal = b.lastMessage || { date: 0 }
229+
const aVal = a.index || 0
230+
const bVal = b.index || 0
231231
232-
return aVal.date > bVal.date ? -1 : bVal.date > aVal.date ? 1 : 0
232+
return aVal > bVal ? -1 : bVal > aVal ? 1 : 0
233233
})
234234
}
235235
},

0 commit comments

Comments
 (0)