From 999b0aab063619dc125b5b67878d2dc5fd191774 Mon Sep 17 00:00:00 2001 From: krustowski Date: Sat, 7 Sep 2024 21:21:22 +0200 Subject: [PATCH] tweak the reply count calculation (wip), update docs --- .env.example | 2 +- api/swagger.json | 2 +- pkg/backend/posts/paginate.go | 9 +++++++++ pkg/backend/router.go | 2 +- pkg/frontend/flow.go | 5 +++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index d7ab781b..c4c301b6 100644 --- a/.env.example +++ b/.env.example @@ -3,5 +3,5 @@ # APP_NAME=littr -APP_VERSION=0.39.21 +APP_VERSION=0.39.22 GOLANG_VERSION=1.23 diff --git a/api/swagger.json b/api/swagger.json index 09bff8a2..0a054346 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -13,7 +13,7 @@ "name": "MIT", "url": "https://github.com/krustowski/littr/blob/master/LICENSE" }, - "version": "0.39.21" + "version": "0.39.22" }, "host": "www.littr.eu", "basePath": "/api/v1", diff --git a/pkg/backend/posts/paginate.go b/pkg/backend/posts/paginate.go index 4e0ab73e..617f3108 100644 --- a/pkg/backend/posts/paginate.go +++ b/pkg/backend/posts/paginate.go @@ -60,6 +60,15 @@ func GetOnePage(opts PageOptions) (map[string]models.Post, map[string]models.Use // filter out all posts for such callerID for _, post := range allPosts { + // calculate the reply count for each post + /*if post.ReplyToID != "" { + origo, found := allPosts[post.ReplyToID] + if found { + origo.ReplyCount++ + allPosts[post.ReplyToID] = origo + } + }*/ + // check the caller's flow list, skip on unfollowed, or unknown user if value, found := flowList[post.Nickname]; !found || !value { continue diff --git a/pkg/backend/router.go b/pkg/backend/router.go index 2e9a669c..d13291ee 100644 --- a/pkg/backend/router.go +++ b/pkg/backend/router.go @@ -1,5 +1,5 @@ // @title littr -// @version 0.39.21 +// @version 0.39.22 // @description a simple nanoblogging platform as PWA built on go-app framework // @termsOfService https://littr.eu/tos diff --git a/pkg/frontend/flow.go b/pkg/frontend/flow.go index 8da8827d..94ca425b 100644 --- a/pkg/frontend/flow.go +++ b/pkg/frontend/flow.go @@ -1327,7 +1327,6 @@ func (c *flowContent) Render() app.UI { // prepare reply parameters to render if post.ReplyToID != "" { - //c.posts[post.ReplyToID].ReplyCount++ if previous, found := c.posts[post.ReplyToID]; found { if value, foundU := c.user.FlowList[previous.Nickname]; (!value || !foundU) && c.users[previous.Nickname].Private { previousContent = "this content is private" @@ -1545,7 +1544,9 @@ func (c *flowContent) Render() app.UI { app.Text(postTimestamp), ), app.If(post.Nickname != "system", - //app.B().Text(post.ReplyCount).Class("left-padding"), + app.If(post.ReplyCount > 0, + app.B().Title("reply count").Text(post.ReplyCount).Class("left-padding"), + ), app.Button().Title("reply").ID(key).Class("transparent circle").OnClick(c.onClickReply).Disabled(c.buttonDisabled).Body( app.I().Text("reply"), ),