summaryrefslogtreecommitdiff
path: root/tables.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-01-14 10:06:15 +0300
committerGrail Finder <wohilas@gmail.com>2026-01-14 10:06:15 +0300
commit3b542421e35180db9b9f972ee973befc42f1a46f (patch)
tree8a265754a18bb100eaa5cd301dec2572d6c3cde5 /tables.go
parente120a629397a8c594497bd61b8b1d9e5c0babf78 (diff)
Enha: sort chat table (by updated_at)
Diffstat (limited to 'tables.go')
-rw-r--r--tables.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/tables.go b/tables.go
index a88b501..9cad515 100644
--- a/tables.go
+++ b/tables.go
@@ -23,6 +23,15 @@ func makeChatTable(chatMap map[string]models.Chat) *tview.Table {
chatList[i] = name
i++
}
+ // Sort chatList by UpdatedAt field in descending order (most recent first)
+ for i := 0; i < len(chatList)-1; i++ {
+ for j := i + 1; j < len(chatList); j++ {
+ if chatMap[chatList[i]].UpdatedAt.Before(chatMap[chatList[j]].UpdatedAt) {
+ // Swap chatList[i] and chatList[j]
+ chatList[i], chatList[j] = chatList[j], chatList[i]
+ }
+ }
+ }
// Add 1 extra row for header
rows, cols := len(chatMap)+1, len(actions)+4 // +2 for name, +2 for timestamps
chatActTable := tview.NewTable().