Skip to content

Commit c2ded57

Browse files
committed
fix: threads sync data and orders
1 parent aa9f02f commit c2ded57

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

apps/frontend/app/components/chat/ChatSidebar.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ if ($auth.loggedIn) {
5252
// Keep threads that are not assigned to any users
5353
// Must reconstruct array or else it cant be cloned to IDB.
5454
threads.value = JSON.parse(JSON.stringify(
55-
[...tFC, ...threads.value.filter(t => !t.userId)],
55+
[
56+
...threads.value.filter(t => !t.userId),
57+
...tFC,
58+
].sort((a, b) => b.timestamp - a.timestamp),
5659
))
5760
})
5861
watch(fetchingFromConvex, (fFC) => {
@@ -72,9 +75,9 @@ else {
7275
// Must reconstruct array or else it cant be cloned to IDB.
7376
threads.value = JSON.parse(JSON.stringify(
7477
[
75-
...tFC.map(t => ({ ...t, lockerKey: getLockerKey(t._id) })),
7678
...threads.value.filter(t => !t.userId && t.sessionId !== $init.sessionId),
77-
],
79+
...tFC.map(t => ({ ...t, lockerKey: getLockerKey(t._id) })),
80+
].sort((a, b) => b.timestamp - a.timestamp),
7881
))
7982
})
8083
watch(fetchingFromConvex, (fFC) => {

0 commit comments

Comments
 (0)