mirror of https://github.com/miniflux/v2.git
Mark only globally visible entries when marking all entries from UI
This commit is contained in:
parent
31c4172540
commit
118e18190d
|
@ -449,6 +449,33 @@ func (s *Storage) MarkAllAsRead(userID int64) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarkGloballyVisibleFeedsAsRead updates all user entries to the read status.
|
||||||
|
func (s *Storage) MarkGloballyVisibleFeedsAsRead(userID int64) error {
|
||||||
|
query := `
|
||||||
|
UPDATE
|
||||||
|
entries
|
||||||
|
SET
|
||||||
|
status=$1,
|
||||||
|
changed_at=now()
|
||||||
|
FROM
|
||||||
|
feeds
|
||||||
|
WHERE
|
||||||
|
entries.feed_id = feeds.id
|
||||||
|
AND entries.user_id=$2
|
||||||
|
AND entries.status=$3
|
||||||
|
AND feeds.hide_globally=$4
|
||||||
|
`
|
||||||
|
result, err := s.db.Exec(query, model.EntryStatusRead, userID, model.EntryStatusUnread, false)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf(`store: unable to mark globally visible feeds as read: %v`, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
count, _ := result.RowsAffected()
|
||||||
|
logger.Debug("[Storage:MarkGloballyVisibleFeedsAsRead] %d items marked as read", count)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// MarkFeedAsRead updates all feed entries to the read status.
|
// MarkFeedAsRead updates all feed entries to the read status.
|
||||||
func (s *Storage) MarkFeedAsRead(userID, feedID int64, before time.Time) error {
|
func (s *Storage) MarkFeedAsRead(userID, feedID int64, before time.Time) error {
|
||||||
query := `
|
query := `
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *handler) markAllAsRead(w http.ResponseWriter, r *http.Request) {
|
func (h *handler) markAllAsRead(w http.ResponseWriter, r *http.Request) {
|
||||||
if err := h.store.MarkAllAsRead(request.UserID(r)); err != nil {
|
if err := h.store.MarkGloballyVisibleFeedsAsRead(request.UserID(r)); err != nil {
|
||||||
json.ServerError(w, r, err)
|
json.ServerError(w, r, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue