From 1b97bbb2d904d804abc2c4594a1556995a839e18 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Fri, 28 Jun 2024 22:53:46 -0500 Subject: [PATCH] Remove post descriptions from timelines by default --- src/db/db.go | 1 + src/hmndata/timeline_helper.go | 6 ++++++ src/models/timeline_item.go | 22 ++++++++++++---------- todo-styles.md | 4 +++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/db/db.go b/src/db/db.go index 6628db83..1cf682ff 100644 --- a/src/db/db.go +++ b/src/db/db.go @@ -479,6 +479,7 @@ This is common for custom types like: */ var queryableKinds = []reflect.Kind{ reflect.Int, + reflect.String, } /* diff --git a/src/hmndata/timeline_helper.go b/src/hmndata/timeline_helper.go index 719b3462..55f6a51a 100644 --- a/src/hmndata/timeline_helper.go +++ b/src/hmndata/timeline_helper.go @@ -69,6 +69,8 @@ type TimelineQuery struct { SkipSnippets bool SkipPosts bool + IncludePostDescription bool + Limit, Offset int } @@ -252,6 +254,10 @@ func FetchTimeline( if results[idx].Owner != nil { results[idx].Owner.AvatarAsset = results[idx].AvatarAsset } + if results[idx].Item.Type == models.TimelineItemTypePost && !q.IncludePostDescription { + results[idx].Item.RawDescription = "" + results[idx].Item.ParsedDescription = "" + } } var projectIds []int diff --git a/src/models/timeline_item.go b/src/models/timeline_item.go index 3542648f..1e9193fb 100644 --- a/src/models/timeline_item.go +++ b/src/models/timeline_item.go @@ -6,23 +6,25 @@ import ( "github.com/google/uuid" ) +type TimelineItemType string + const ( - TimelineItemTypeSnippet = "snippet" - TimelineItemTypePost = "post" - TimelineItemTypeStream = "stream" // NOTE(asaf): Not currently supported + TimelineItemTypeSnippet TimelineItemType = "snippet" + TimelineItemTypePost TimelineItemType = "post" + TimelineItemTypeStream TimelineItemType = "stream" // NOTE(asaf): Not currently supported ) // NOTE(asaf): This is a virtual model made up of several different tables type TimelineItem struct { // Common // NOTE(asaf): Several different items can have the same ID because we're merging several tables - ID int `db:"id"` - Date time.Time `db:"\"when\""` - Type string `db:"timeline_type"` - OwnerID int `db:"owner_id"` - Title string `db:"title"` - ParsedDescription string `db:"parsed_desc"` - RawDescription string `db:"raw_desc"` + ID int `db:"id"` + Date time.Time `db:"\"when\""` + Type TimelineItemType `db:"timeline_type"` + OwnerID int `db:"owner_id"` + Title string `db:"title"` + ParsedDescription string `db:"parsed_desc"` + RawDescription string `db:"raw_desc"` // Snippet AssetID *uuid.UUID `db:"asset_id"` diff --git a/todo-styles.md b/todo-styles.md index a3f3b816..f3818a14 100644 --- a/todo-styles.md +++ b/todo-styles.md @@ -56,7 +56,9 @@ - TikTok? - Trello? - [ ] Handle empty avatar URLs correctly in various places (render as theme-dependent default) -- [ ] Convert to new color vars +- [x] Convert to new color vars +- [ ] Make snippet descriptions partially collapse by default +- [ ] Make the home page remember which tab you were on - [ ] Resolve TODO(redesign) comments stack!