Jan-Lukas Else 4 years ago
parent
commit
ce6fa4c0fc
2 changed files with 9 additions and 1 deletions
  1. 8 1
      storage/entry_pagination_builder.go
  2. 1 0
      ui/entry_unread.go

+ 8 - 1
storage/entry_pagination_builder.go

@@ -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.
 func (e *EntryPaginationBuilder) Entries() (*model.Entry, *model.Entry, error) {
 	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,
 				lead(e.id) over (order by e.published_at asc, e.id desc) as next_id
 			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
 			ORDER BY e.published_at asc, e.id desc
 		)

+ 1 - 0
ui/entry_unread.go

@@ -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.WithStatus(model.EntryStatusUnread)
+	entryPaginationBuilder.WithGloballyVisible()
 	prevEntry, nextEntry, err := entryPaginationBuilder.Entries()
 	if err != nil {
 		html.ServerError(w, r, err)