1
0
Fork 0
This commit is contained in:
Jan-Lukas Else 2021-08-15 21:18:24 +02:00 committed by fguillot
parent 9965abccfb
commit ce6fa4c0fc
2 changed files with 9 additions and 1 deletions

View file

@ -60,6 +60,12 @@ func (e *EntryPaginationBuilder) WithStatus(status string) {
} }
} }
// WithGloballyVisible adds global visibility to the condition.
func (e *EntryPaginationBuilder) WithGloballyVisible() {
e.conditions = append(e.conditions, "not c.hide_globally")
e.conditions = append(e.conditions, "not f.hide_globally")
}
// Entries returns previous and next entries. // Entries returns previous and next entries.
func (e *EntryPaginationBuilder) Entries() (*model.Entry, *model.Entry, error) { func (e *EntryPaginationBuilder) Entries() (*model.Entry, *model.Entry, error) {
tx, err := e.store.db.Begin() tx, err := e.store.db.Begin()
@ -104,7 +110,8 @@ func (e *EntryPaginationBuilder) getPrevNextID(tx *sql.Tx) (prevID int64, nextID
lag(e.id) over (order by e.published_at asc, e.id desc) as prev_id, lag(e.id) over (order by e.published_at asc, e.id desc) as prev_id,
lead(e.id) over (order by e.published_at asc, e.id desc) as next_id lead(e.id) over (order by e.published_at asc, e.id desc) as next_id
FROM entries AS e FROM entries AS e
LEFT JOIN feeds AS f ON f.id=e.feed_id JOIN feeds AS f ON f.id=e.feed_id
JOIN categories c ON c.id = f.category_id
WHERE %s WHERE %s
ORDER BY e.published_at asc, e.id desc ORDER BY e.published_at asc, e.id desc
) )

View file

@ -50,6 +50,7 @@ func (h *handler) showUnreadEntryPage(w http.ResponseWriter, r *http.Request) {
entryPaginationBuilder := storage.NewEntryPaginationBuilder(h.store, user.ID, entry.ID, user.EntryDirection) entryPaginationBuilder := storage.NewEntryPaginationBuilder(h.store, user.ID, entry.ID, user.EntryDirection)
entryPaginationBuilder.WithStatus(model.EntryStatusUnread) entryPaginationBuilder.WithStatus(model.EntryStatusUnread)
entryPaginationBuilder.WithGloballyVisible()
prevEntry, nextEntry, err := entryPaginationBuilder.Entries() prevEntry, nextEntry, err := entryPaginationBuilder.Entries()
if err != nil { if err != nil {
html.ServerError(w, r, err) html.ServerError(w, r, err)