link forum list last topics to last pages

This commit is contained in:
Azareal 2020-08-13 13:26:02 +10:00
parent 9fd88bd6bc
commit 40783f00da
2 changed files with 7 additions and 0 deletions

View File

@ -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?

View File

@ -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