reduce GetPinnedPosts calls to single line
This commit is contained in:
parent
b373aad298
commit
f241d69425
|
@ -783,11 +783,7 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
|
|||
|
||||
// Add more data
|
||||
// TODO: fix this mess of collections inside collections
|
||||
if isOwner {
|
||||
displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj, true)
|
||||
} else {
|
||||
displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj, false)
|
||||
}
|
||||
displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj, isOwner)
|
||||
|
||||
err = templates["collection"].ExecuteTemplate(w, "collection", displayPage)
|
||||
if err != nil {
|
||||
|
@ -884,11 +880,7 @@ func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) e
|
|||
coll.Owner = displayPage.Owner
|
||||
// Add more data
|
||||
// TODO: fix this mess of collections inside collections
|
||||
if isOwner {
|
||||
displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj, true)
|
||||
} else {
|
||||
displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj, false)
|
||||
}
|
||||
displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj, isOwner)
|
||||
|
||||
err = templates["collection-tags"].ExecuteTemplate(w, "collection-tags", displayPage)
|
||||
if err != nil {
|
||||
|
|
6
posts.go
6
posts.go
|
@ -1380,11 +1380,7 @@ Are you sure it was ever here?`,
|
|||
IsCustomDomain: cr.isCustomDomain,
|
||||
IsFound: postFound,
|
||||
}
|
||||
if p.IsOwner {
|
||||
tp.PinnedPosts, _ = app.db.GetPinnedPosts(coll, true)
|
||||
} else {
|
||||
tp.PinnedPosts, _ = app.db.GetPinnedPosts(coll, false)
|
||||
}
|
||||
tp.PinnedPosts, _ = app.db.GetPinnedPosts(coll, p.IsOwner)
|
||||
tp.IsPinned = len(*tp.PinnedPosts) > 0 && PostsContains(tp.PinnedPosts, p)
|
||||
|
||||
if !postFound {
|
||||
|
|
Loading…
Reference in New Issue