feat: sort dms by latest message (#543)
This commit is contained in:
parent
232f4d469b
commit
662fbf4c6a
1 changed files with 10 additions and 0 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue