From a0155bfc5e4f74f118f8406e9c47f12b0e0e4ddb Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Mon, 3 May 2021 17:53:28 -0500 Subject: [PATCH] Get read/unread working on forum index --- src/website/forums.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/website/forums.go b/src/website/forums.go index 00430087..1064e77f 100644 --- a/src/website/forums.go +++ b/src/website/forums.go @@ -117,6 +117,13 @@ func ForumCategory(c *RequestContext) ResponseData { for _, irow := range itMainThreads.ToSlice() { row := irow.(*mainPostsQueryResult) + hasRead := false + if row.ThreadLastReadTime != nil && row.ThreadLastReadTime.After(row.LastPost.PostDate) { + hasRead = true + } else if row.CatLastReadTime != nil && row.CatLastReadTime.After(row.LastPost.PostDate) { + hasRead = true + } + threads = append(threads, templates.ThreadListItem{ Title: row.Thread.Title, Url: ThreadUrl(row.Thread, models.CatKindForum, categoryUrls[currentCatId]), @@ -125,6 +132,8 @@ func ForumCategory(c *RequestContext) ResponseData { FirstDate: row.FirstPost.PostDate, LastUser: templates.UserToTemplate(row.LastUser), LastDate: row.LastPost.PostDate, + + Unread: !hasRead, }) }