summaryrefslogtreecommitdiff
path: root/doPlayback.go
diff options
context:
space:
mode:
authorCastor Gemini <[email protected]>2025-08-22 04:30:02 -0500
committerJeff Carr <[email protected]>2025-08-22 04:30:02 -0500
commit0e6bc3698454cfa718d127880bb7dc89486102b1 (patch)
tree32a31e94b5e4ae14e4f355cc68d512013cf6fc49 /doPlayback.go
parentd0c27606a3f3881da42cd33955f846b954cd32ff (diff)
feat(playback): Implement listEntries for chat summary
- Implement a new 'listEntries' function that provides a one-line summary for each entry within a chat topic. - The 'showChat' function (triggered by 'playback --uuid') now calls this new summary view.
Diffstat (limited to 'doPlayback.go')
-rw-r--r--doPlayback.go34
1 files changed, 29 insertions, 5 deletions
diff --git a/doPlayback.go b/doPlayback.go
index 019db68..2711598 100644
--- a/doPlayback.go
+++ b/doPlayback.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "strings"
"go.wit.com/lib/protobuf/chatpb"
"go.wit.com/log"
@@ -22,8 +23,7 @@ func showChat(uuid string) {
log.Info("unknown uuid", uuid)
return
}
- // Call the new, dedicated formatting function.
- prettyFormatChat(chat)
+ listEntries(chat)
}
func listChats(chats *chatpb.Chats) {
@@ -46,13 +46,37 @@ func listChats(chats *chatpb.Chats) {
formattedTime,
chat.GetUuid(),
)
- if argv.Playback.Long != nil {
- listEntries(chat)
- }
}
fmt.Println("-------------------------------------------------")
}
// print out one line for each chat entry
func listEntries(chat *chatpb.Chat) {
+ fmt.Printf("\n--- Entries for Topic: %s ---\n", chat.GetChatName())
+ for i, entry := range chat.GetEntries() {
+ author := entry.GetFrom().String()
+ var formattedTime string
+ if ctime := entry.GetCtime(); ctime != nil {
+ t := ctime.AsTime()
+ formattedTime = t.Format("15:04:05") // Just the time for entry summary
+ } else {
+ formattedTime = "No Time"
+ }
+
+ // Create a short preview of the content
+ contentPreview := strings.TrimSpace(entry.GetContent())
+ if len(contentPreview) > 60 {
+ contentPreview = contentPreview[:57] + "..."
+ }
+ // Replace newlines with spaces for a clean one-line view
+ contentPreview = strings.ReplaceAll(contentPreview, "\n", " ")
+
+ fmt.Printf(" %2d. [%s] (%s): %s\n",
+ i+1,
+ author,
+ formattedTime,
+ contentPreview,
+ )
+ }
+ fmt.Println("-------------------------------------------------")
}