reduce GetPinnedPosts calls to single line

This commit is contained in:
Rob Loranger 2019-08-12 14:12:35 -07:00
parent b373aad298
commit f241d69425
No known key found for this signature in database
GPG Key ID: D6F1633A4F0903B8
2 changed files with 3 additions and 15 deletions

View File

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

View File

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