Skip to content

Commit

Permalink
fix: DM sorting by last message on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkothari22 committed Apr 10, 2024
1 parent c5f0da8 commit 0d99e05
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mobile/src/pages/direct-messages/DirectMessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,9 @@ const useMessageUsersList = () => {
})

return usersWithChannels.sort((a, b) => {
if (a.channel && b.channel) {
const bTimestamp = b.channel.last_message_timestamp ? new Date(b.channel.last_message_timestamp).getTime() : 0
const aTimestamp = a.channel.last_message_timestamp ? new Date(a.channel.last_message_timestamp).getTime() : 0
return new Date(bTimestamp).getTime() - new Date(aTimestamp).getTime()
}
return 0
const bTimestamp = b.channel?.last_message_timestamp ? new Date(b.channel.last_message_timestamp).getTime() : 0
const aTimestamp = a.channel?.last_message_timestamp ? new Date(a.channel.last_message_timestamp).getTime() : 0
return bTimestamp - aTimestamp
})
}, [users, dm_channels])

Expand Down

0 comments on commit 0d99e05

Please sign in to comment.