summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-04-18 17:36:26 +0200
committerLibravatar GitHub <noreply@github.com>2025-04-18 17:36:26 +0200
commit2fce02780876d5e4c4f32e0ca341c43a5d8b21a8 (patch)
tree409adbe897de49e6ae2ca0dedbec4bfd044e10fd /internal/typeutils/internaltofrontend.go
parent[chore] Don't push `latest` Docker image on prerelease (#4017) (diff)
downloadgotosocial-2fce02780876d5e4c4f32e0ca341c43a5d8b21a8.tar.xz
[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
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r--internal/typeutils/internaltofrontend.go39
1 files changed, 39 insertions, 0 deletions
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.