From 812136357e9ee2bf4aa940f64b3ebcfeed9a06e7 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 9 Jan 2020 16:48:22 -0500 Subject: [PATCH] Move Format from DisplayCollection to CollectionObj --- collections.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/collections.go b/collections.go index 66ad7a0..5c9a1b7 100644 --- a/collections.go +++ b/collections.go @@ -63,6 +63,7 @@ type ( TotalPosts int `json:"total_posts"` Owner *User `json:"owner,omitempty"` Posts *[]PublicPost `json:"posts,omitempty"` + Format *CollectionFormat } DisplayCollection struct { *CollectionObj @@ -70,7 +71,6 @@ type ( IsTopLevel bool CurrentPage int TotalPages int - Format *CollectionFormat Suspended bool } SubmittedCollection struct { @@ -556,6 +556,13 @@ type CollectionPage struct { CanInvite bool } +func NewCollectionObj(c *Collection) *CollectionObj { + return &CollectionObj{ + Collection: *c, + Format: c.NewFormat(), + } +} + func (c *CollectionObj) ScriptDisplay() template.JS { return template.JS(c.Script) } @@ -705,11 +712,10 @@ func checkUserForCollection(app *App, cr *collectionReq, r *http.Request, isPost func newDisplayCollection(c *Collection, cr *collectionReq, page int) *DisplayCollection { coll := &DisplayCollection{ - CollectionObj: &CollectionObj{Collection: *c}, + CollectionObj: NewCollectionObj(c), CurrentPage: page, Prefix: cr.prefix, IsTopLevel: isSingleUser, - Format: c.NewFormat(), } c.db.GetPostsCount(coll.CollectionObj, cr.isCollOwner) return coll