1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Make sure we always get the pagination in unread mode

This commit is contained in:
Frédéric Guillot 2018-06-29 20:29:04 -07:00
parent 0b0f4751fa
commit 77947282e4
4 changed files with 19 additions and 15 deletions

View file

@ -49,6 +49,16 @@ func (c *Controller) ShowUnreadEntry(w http.ResponseWriter, r *http.Request) {
return
}
// Make sure we always get the pagination in unread mode even if the page is refreshed.
if entry.Status == model.EntryStatusRead {
err = c.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusUnread)
if err != nil {
logger.Error("[Controller:ShowUnreadEntry] %v", err)
html.ServerError(w, nil)
return
}
}
entryPaginationBuilder := storage.NewEntryPaginationBuilder(c.store, user.ID, entry.ID, user.EntryDirection)
entryPaginationBuilder.WithStatus(model.EntryStatusUnread)
prevEntry, nextEntry, err := entryPaginationBuilder.Entries()
@ -86,8 +96,10 @@ func (c *Controller) ShowUnreadEntry(w http.ResponseWriter, r *http.Request) {
view.Set("prevEntryRoute", prevEntryRoute)
view.Set("menu", "unread")
view.Set("user", user)
view.Set("countUnread", c.store.CountUnreadEntries(user.ID))
view.Set("hasSaveEntry", c.store.HasSaveEntry(user.ID))
// Fetching the counter here avoid to be off by one.
view.Set("countUnread", c.store.CountUnreadEntries(user.ID))
html.OK(w, view.Render("entry"))
}