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/typeutils/internaltofrontend.go | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'internal/typeutils/internaltofrontend.go') 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.2.3