Skip to content

Commit d7c504f

Browse files
committed
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.
1 parent 6ad2001 commit d7c504f

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

internal/storage/entry.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -369,20 +369,10 @@ func (s *Storage) ArchiveEntries(status string, days, limit int) (int64, error)
369369
// SetEntriesStatus update the status of the given list of entries.
370370
func (s *Storage) SetEntriesStatus(userID int64, entryIDs []int64, status string) error {
371371
query := `UPDATE entries SET status=$1, changed_at=now() WHERE user_id=$2 AND id=ANY($3)`
372-
result, err := s.db.Exec(query, status, userID, pq.Array(entryIDs))
373-
if err != nil {
372+
if _, err := s.db.Exec(query, status, userID, pq.Array(entryIDs)); err != nil {
374373
return fmt.Errorf(`store: unable to update entries statuses %v: %v`, entryIDs, err)
375374
}
376375

377-
count, err := result.RowsAffected()
378-
if err != nil {
379-
return fmt.Errorf(`store: unable to update these entries %v: %v`, entryIDs, err)
380-
}
381-
382-
if count == 0 {
383-
return errors.New(`store: nothing has been updated`)
384-
}
385-
386376
return nil
387377
}
388378

0 commit comments

Comments
 (0)