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

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2018-06-19 22:56:40.310658103 -0700 PDT m=+0.032470223
// 2018-06-29 20:26:34.578915833 -0700 PDT m=+0.035901799
package template
@ -529,7 +529,7 @@ var templateViewsMap = map[string]string{
data-label-loading="{{ t "Saving..." }}"
data-label-star="☆ {{ t "Star" }}"
data-label-unstar="★ {{ t "Unstar" }}"
data-value="{{ if .Starred }}star{{ else }}unstar{{ end }}"
data-value="{{ if .entry.Starred }}star{{ else }}unstar{{ end }}"
>{{ if .entry.Starred }} {{ t "Unstar" }}{{ else }} {{ t "Star" }}{{ end }}</a>
</li>
{{ if .hasSaveEntry }}
@ -1278,7 +1278,7 @@ var templateViewsMapChecksums = map[string]string{
"edit_category": "cee720faadcec58289b707ad30af623d2ee66c1ce23a732965463250d7ff41c5",
"edit_feed": "66dd3ca6357645944a99f8b9c0455253e6d2bf5f36faf9aa322689b6299b0104",
"edit_user": "321e0a60cf3bf7441bff970f4920e4c5b7c1883f80ab1d1674f8137954b25033",
"entry": "bd611521ebb46714fce434fe7fa5d4e53e50da4c3ed02450ad3557f614f16e14",
"entry": "aa7a7e6349a0243bee8629dbcfdd94e21da193df7ef5af0b5aab39ab8c793279",
"feed_entries": "4dffdb55cfad29df20612efe7ed2dbed03d919c4556898543ab6450f610d3c99",
"feeds": "2a5abe37968ea34a0576dbef52341645cb1fc9562e351382fbf721491da6f4fa",
"history_entries": "451f0b202f47c9db5344d3e73862f5b7afbd4323fbdba21b6087866c40f045d3",

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"))
}

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2018-06-28 02:11:57.050292961 -0400 EDT m=+0.005178557
// 2018-06-29 20:26:34.577543639 -0700 PDT m=+0.034529605
package static
@ -74,8 +74,7 @@ let currentItem=document.querySelector(".current-item");if(currentItem!==null){t
toggleBookmarkLink(parent){let bookmarkLink=parent.querySelector("a[data-toggle-bookmark]");if(bookmarkLink){EntryHandler.toggleBookmark(bookmarkLink);}}
openOriginalLink(){let entryLink=document.querySelector(".entry h1 a");if(entryLink!==null){DomHelper.openNewTab(entryLink.getAttribute("href"));return;}
let currentItemOriginalLink=document.querySelector(".current-item a[data-original-link]");if(currentItemOriginalLink!==null){DomHelper.openNewTab(currentItemOriginalLink.getAttribute("href"));let currentItem=document.querySelector(".current-item");this.goToNextListItem();EntryHandler.markEntryAsRead(currentItem);}}
openSelectedItem(){let currentItemLink=document.querySelector(".current-item .item-title a");if(currentItemLink!==null){let currentItemOriginalLink=document.querySelector(".current-item a[data-original-link]");if(currentItemOriginalLink!==null){let currentItem=document.querySelector(".current-item");EntryHandler.markEntryAsRead(currentItem);}
window.location.href=currentItemLink.getAttribute("href");}}
openSelectedItem(){let currentItemLink=document.querySelector(".current-item .item-title a");if(currentItemLink!==null){window.location.href=currentItemLink.getAttribute("href");}}
goToPage(page,fallbackSelf){let element=document.querySelector("a[data-page="+page+"]");if(element){document.location.href=element.href;}else if(fallbackSelf){window.location.reload();}}
goToPrevious(){if(this.isListView()){this.goToPreviousListItem();}else{this.goToPage("previous");}}
goToNext(){if(this.isListView()){this.goToNextListItem();}else{this.goToPage("next");}}
@ -92,5 +91,5 @@ document.addEventListener("DOMContentLoaded",function(){FormHandler.handleSubmit
}
var JavascriptChecksums = map[string]string{
"app": "803826d0f7d801ed07437712668d00247112b6f85eae5b1b46f3ac9f95fe2b18",
"app": "1cbc164e7e61cb058564c41d63530cfb8936c63b061b0381f7672f8010be70dd",
}

View file

@ -637,13 +637,6 @@ class NavHandler {
openSelectedItem() {
let currentItemLink = document.querySelector(".current-item .item-title a");
if (currentItemLink !== null) {
// The following 4 lines ensure that the unread count in the menu is
// updated correctly when users presses "o".
let currentItemOriginalLink = document.querySelector(".current-item a[data-original-link]");
if (currentItemOriginalLink !== null) {
let currentItem = document.querySelector(".current-item");
EntryHandler.markEntryAsRead(currentItem);
}
window.location.href = currentItemLink.getAttribute("href");
}
}