From 2fce02780876d5e4c4f32e0ca341c43a5d8b21a8 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 18 Apr 2025 17:36:26 +0200 Subject: [feature/frontend] Hide "engagement" stats, edits, and other info under a little drop down to unclutter status info bar (#4021) * dick about with stats a bit * more dicking abuot * lil tweaks * more about-dicking * weee * comments * fixie uppie --- internal/api/model/status.go | 6 +++++ internal/typeutils/internaltofrontend.go | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) (limited to 'internal') diff --git a/internal/api/model/status.go b/internal/api/model/status.go index ec09f702d..bcd0c0f93 100644 --- a/internal/api/model/status.go +++ b/internal/api/model/status.go @@ -166,6 +166,12 @@ type WebStatus struct { // after the "main" thread, so it and everything // below it can be considered "replies". ThreadFirstReply bool + + // Sorted slice of StatusEdit times for + // this status, from latest to oldest. + // Only set if status has been edited. + // Last entry is always creation time. + EditTimeline []string `json:"-"` } /* diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 91c9fea8a..2c662c3bd 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -1217,6 +1217,45 @@ func (c *Converter) StatusToWebStatus( // Mark local. webStatus.Local = *s.Local + // Get edit history for this + // status, if it's been edited. + if webStatus.EditedAt != nil { + // Make sure edits are populated. + if len(s.Edits) != len(s.EditIDs) { + s.Edits, err = c.state.DB.GetStatusEditsByIDs(ctx, s.EditIDs) + if err != nil && !errors.Is(err, db.ErrNoEntries) { + err := gtserror.Newf("db error getting status edits: %w", err) + return nil, err + } + } + + // Include each historical entry + // (this includes the created date). + for _, edit := range s.Edits { + webStatus.EditTimeline = append( + webStatus.EditTimeline, + util.FormatISO8601(edit.CreatedAt), + ) + } + + // Make sure to include latest revision. + webStatus.EditTimeline = append( + webStatus.EditTimeline, + *webStatus.EditedAt, + ) + + // Sort the slice so it goes from + // newest -> oldest, like a timeline. + // + // It'll look something like: + // + // - edit3 date (ie., latest version) + // - edit2 date (if we have it) + // - edit1 date (if we have it) + // - created date + slices.Reverse(webStatus.EditTimeline) + } + // Set additional templating // variables on media attachments. -- cgit v1.3