FirstID and LastID are not nullable

This commit is contained in:
Ben Visness 2021-07-30 15:01:40 -05:00
parent b0f75675c8
commit 93318c378a
5 changed files with 6 additions and 6 deletions

View File

@ -25,6 +25,6 @@ type Thread struct {
Locked bool `db:"locked"`
Deleted bool `db:"deleted"`
FirstID *int `db:"first_id"`
LastID *int `db:"last_id"`
FirstID int `db:"first_id"`
LastID int `db:"last_id"`
}

View File

@ -505,7 +505,7 @@ func ForumThread(c *RequestContext) ResponseData {
Thread: templates.ThreadToTemplate(&thread),
Posts: posts,
SubforumUrl: hmnurl.BuildForum(c.CurrentProject.Slug, currentSubforumSlugs, 1),
ReplyUrl: hmnurl.BuildForumPostReply(c.CurrentProject.Slug, currentSubforumSlugs, thread.ID, *thread.FirstID),
ReplyUrl: hmnurl.BuildForumPostReply(c.CurrentProject.Slug, currentSubforumSlugs, thread.ID, thread.FirstID),
Pagination: pagination,
}, c.Perf)
return res

View File

@ -156,7 +156,7 @@ func Index(c *RequestContext) ResponseData {
featurable := (!proj.IsHMN() &&
projectPost.Post.ThreadType == models.ThreadTypeProjectArticle &&
*projectPost.Thread.FirstID == projectPost.Post.ID &&
projectPost.Thread.FirstID == projectPost.Post.ID &&
landingPageProject.FeaturedPost == nil)
if featurable {

View File

@ -78,7 +78,7 @@ func MakePostListItem(
postTypeOptions, found := PostTypeMap[post.ThreadType]
if found {
isNotFirst := 0
if *thread.FirstID != post.ID {
if thread.FirstID != post.ID {
isNotFirst = 1
}
postType = postTypeOptions[isNotFirst]

View File

@ -51,7 +51,7 @@ func PostToTimelineItem(lineageBuilder *models.SubforumLineageBuilder, post *mod
typeByCatKind, found := TimelineTypeMap[post.ThreadType]
if found {
isNotFirst := 0
if *thread.FirstID != post.ID {
if thread.FirstID != post.ID {
isNotFirst = 1
}
itemType = typeByCatKind[isNotFirst]