feat: sort dms by latest message (#543)

This commit is contained in:
N1cky 2025-05-16 00:42:41 -03:00 • committed by GitHub
parent 232f4d469b
commit 662fbf4c6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -211,6 +211,16 @@ func (gt *GuildsTree) onSelected(n *tview.TreeNode) {
return
}
sort.Slice(cs, func(a, b int) bool {
msgID := func(ch discord.Channel) discord.MessageID {
if ch.LastMessageID.IsValid() {
return ch.LastMessageID
}
return discord.MessageID(ch.ID)
}
return msgID(cs[a]) > msgID(cs[b])
})
for _, c := range cs {
gt.createChannelNode(n, c)
}