reduce GetPinnedPosts calls to single line

pull/169/head
Rob Loranger 5 years ago
parent b373aad298
commit f241d69425
No known key found for this signature in database
GPG Key ID: D6F1633A4F0903B8
  1. 12
      collections.go
  2. 6
      posts.go

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

@ -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…
Cancel
Save