fix: update the status list printer function

- Show whether a status is a boost, a reply to another status or a
  normal post.
- Move the "Created At" field to a new line.
- Show the date and time when a status was boosted.
This commit is contained in:
Dan Anglin 2024-07-10 09:14:13 +01:00
parent 2bb801b6d0
commit 6e260266b1
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638

View file

@ -82,27 +82,39 @@ func (p Printer) PrintStatusList(list model.StatusList) {
builder.WriteString(p.headerFormat(list.Name) + "\n") builder.WriteString(p.headerFormat(list.Name) + "\n")
for _, status := range list.Statuses { for _, status := range list.Statuses {
builder.WriteString("\n" + p.fullDisplayNameFormat(status.Account.DisplayName, status.Account.Acct))
statusID := status.ID statusID := status.ID
createdAt := status.CreatedAt createdAt := p.formatDateTime(status.CreatedAt)
boostedAt := ""
content := status.Content content := status.Content
poll := status.Poll poll := status.Poll
mediaAttachments := status.MediaAttachments mediaAttachments := status.MediaAttachments
if status.Reblog != nil { switch {
builder.WriteString( case status.Reblog != nil:
"\n" + p.wrapLines( builder.WriteString("\n" + p.wrapLines(
"reposted this status from "+p.fullDisplayNameFormat(status.Reblog.Account.DisplayName, status.Reblog.Account.Acct), p.fullDisplayNameFormat(status.Account.DisplayName, status.Account.Acct)+
" boosted this status from "+
p.fullDisplayNameFormat(status.Reblog.Account.DisplayName, status.Reblog.Account.Acct)+
":",
0, 0,
), ))
)
statusID = status.Reblog.ID statusID = status.Reblog.ID
createdAt = status.Reblog.CreatedAt createdAt = p.formatDateTime(status.Reblog.CreatedAt)
boostedAt = p.formatDateTime(status.CreatedAt)
content = status.Reblog.Content content = status.Reblog.Content
poll = status.Reblog.Poll poll = status.Reblog.Poll
mediaAttachments = status.Reblog.MediaAttachments mediaAttachments = status.Reblog.MediaAttachments
case status.InReplyToID != "":
builder.WriteString("\n" + p.wrapLines(
p.fullDisplayNameFormat(status.Account.DisplayName, status.Account.Acct)+
" posted in reply to "+
status.InReplyToID+
":",
0,
))
default:
builder.WriteString("\n" + p.fullDisplayNameFormat(status.Account.DisplayName, status.Account.Acct) + " posted:")
} }
builder.WriteString("\n" + p.convertHTMLToText(content, true)) builder.WriteString("\n" + p.convertHTMLToText(content, true))
@ -147,12 +159,15 @@ func (p Printer) PrintStatusList(list model.StatusList) {
builder.WriteString( builder.WriteString(
"\n\n" + "\n\n" +
p.fieldFormat("Status ID:") + " " + statusID + "\t" + p.fieldFormat("Status ID: ") + statusID +
p.fieldFormat("Created at:") + " " + p.formatDateTime(createdAt) + "\n" + p.fieldFormat("Created at: ") + createdAt,
"\n",
) )
builder.WriteString(p.statusSeparator + "\n") if boostedAt != "" {
builder.WriteString("\n" + p.fieldFormat("Boosted at: ") + boostedAt)
}
builder.WriteString("\n" + p.statusSeparator + "\n")
} }
p.print(builder.String()) p.print(builder.String())