Skip to content

Commit

Permalink
tweak the reply count calculation (wip), update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
krustowski committed Sep 7, 2024
1 parent 525351f commit 999b0aa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#

APP_NAME=littr
APP_VERSION=0.39.21
APP_VERSION=0.39.22
GOLANG_VERSION=1.23
2 changes: 1 addition & 1 deletion api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions pkg/backend/posts/paginate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/router.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 3 additions & 2 deletions pkg/frontend/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"),
),
Expand Down

0 comments on commit 999b0aa

Please sign in to comment.