diff --git a/common/forum.go b/common/forum.go index 1bdf8af9..be16e0fc 100644 --- a/common/forum.go +++ b/common/forum.go @@ -40,6 +40,7 @@ type Forum struct { LastReplyer *User LastReplyerID int LastTopicTime string // So that we can re-calculate the relative time on the spot in /forums/ + LastPage int } // ? - What is this for? diff --git a/common/forum_store.go b/common/forum_store.go index df943863..739f08df 100644 --- a/common/forum_store.go +++ b/common/forum_store.go @@ -130,6 +130,9 @@ func (s *MemoryForumStore) LoadForums() error { f.Link = BuildForumURL(NameToSlug(f.Name), f.ID) f.LastTopic = Topics.DirtyGet(f.LastTopicID) f.LastReplyer = Users.DirtyGet(f.LastReplyerID) + // TODO: Create a specialised function with a bit less overhead for getting the last page for a post count + _, _, lastPage := PageOffset(f.LastTopic.PostCount, 1, Config.ItemsPerPage) + f.LastPage = lastPage addForum(f) } s.forumView.Store(forumView) @@ -211,6 +214,9 @@ func (s *MemoryForumStore) BypassGet(id int) (*Forum, error) { f.Link = BuildForumURL(NameToSlug(f.Name), f.ID) f.LastTopic = Topics.DirtyGet(f.LastTopicID) f.LastReplyer = Users.DirtyGet(f.LastReplyerID) + // TODO: Create a specialised function with a bit less overhead for getting the last page for a post count + _, _, lastPage := PageOffset(f.LastTopic.PostCount, 1, Config.ItemsPerPage) + f.LastPage = lastPage //TopicListThaw.Thaw() return f, err