From a928c0c3da5e06ead295b5f8d1db12824845a3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Wed, 26 Feb 2025 16:25:28 -0800 Subject: [PATCH] fix(ui): avoid 500 error and NaN when marking as read a deleted entry Steps to reproduce: 1. In /unread, open a feed's settings in a new tab. The feed must have unread entries in /unread. 2. In the new tab/window, delete the feed. 3. Without refreshing, mark an entry from the now-deleted feed as read. 4. Result: The total unread count in the UI header switches to NaN. --- internal/storage/entry.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/internal/storage/entry.go b/internal/storage/entry.go index f22a424bc18..171c0cbeafc 100644 --- a/internal/storage/entry.go +++ b/internal/storage/entry.go @@ -369,20 +369,10 @@ func (s *Storage) ArchiveEntries(status string, days, limit int) (int64, error) // SetEntriesStatus update the status of the given list of entries. func (s *Storage) SetEntriesStatus(userID int64, entryIDs []int64, status string) error { query := `UPDATE entries SET status=$1, changed_at=now() WHERE user_id=$2 AND id=ANY($3)` - result, err := s.db.Exec(query, status, userID, pq.Array(entryIDs)) - if err != nil { + if _, err := s.db.Exec(query, status, userID, pq.Array(entryIDs)); err != nil { return fmt.Errorf(`store: unable to update entries statuses %v: %v`, entryIDs, err) } - count, err := result.RowsAffected() - if err != nil { - return fmt.Errorf(`store: unable to update these entries %v: %v`, entryIDs, err) - } - - if count == 0 { - return errors.New(`store: nothing has been updated`) - } - return nil }