1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-07-22 17:18:37 +00:00

Add user setting for marking entry as read on view

This commit is contained in:
xl 2023-03-17 21:56:17 +08:00 committed by Frédéric Guillot
parent 6046a74a64
commit 356d32c6fe
35 changed files with 84 additions and 29 deletions

View file

@ -38,7 +38,7 @@ func (h *handler) showStarredEntryPage(w http.ResponseWriter, r *http.Request) {
return
}
if entry.Status == model.EntryStatusUnread {
if user.MarkReadOnView && entry.Status == model.EntryStatusUnread {
err = h.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
if err != nil {
html.ServerError(w, r, err)

View file

@ -41,7 +41,7 @@ func (h *handler) showCategoryEntryPage(w http.ResponseWriter, r *http.Request)
return
}
if entry.Status == model.EntryStatusUnread {
if user.MarkReadOnView && entry.Status == model.EntryStatusUnread {
err = h.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
if err != nil {
html.ServerError(w, r, err)

View file

@ -41,7 +41,7 @@ func (h *handler) showFeedEntryPage(w http.ResponseWriter, r *http.Request) {
return
}
if entry.Status == model.EntryStatusUnread {
if user.MarkReadOnView && entry.Status == model.EntryStatusUnread {
err = h.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
if err != nil {
html.ServerError(w, r, err)

View file

@ -40,7 +40,7 @@ func (h *handler) showSearchEntryPage(w http.ResponseWriter, r *http.Request) {
return
}
if entry.Status == model.EntryStatusUnread {
if user.MarkReadOnView && entry.Status == model.EntryStatusUnread {
err = h.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
if err != nil {
html.ServerError(w, r, err)

View file

@ -66,13 +66,18 @@ func (h *handler) showUnreadEntryPage(w http.ResponseWriter, r *http.Request) {
prevEntryRoute = route.Path(h.router, "unreadEntry", "entryID", prevEntry.ID)
}
// Always mark the entry as read after fetching the pagination.
err = h.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
if err != nil {
html.ServerError(w, r, err)
return
if user.MarkReadOnView {
entry.Status = model.EntryStatusRead
}
// Restore entry read status if needed after fetching the pagination.
if entry.Status == model.EntryStatusRead {
err = h.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
if err != nil {
html.ServerError(w, r, err)
return
}
}
entry.Status = model.EntryStatusRead
sess := session.New(h.store, request.SessionID(r))
view := view.New(h.tpl, r, sess)

View file

@ -32,6 +32,7 @@ type SettingsForm struct {
CJKReadingSpeed int
DefaultHomePage string
CategoriesSortingOrder string
MarkReadOnView bool
}
// Merge updates the fields of the given user.
@ -53,6 +54,7 @@ func (s *SettingsForm) Merge(user *model.User) *model.User {
user.DefaultReadingSpeed = s.DefaultReadingSpeed
user.DefaultHomePage = s.DefaultHomePage
user.CategoriesSortingOrder = s.CategoriesSortingOrder
user.MarkReadOnView = s.MarkReadOnView
if s.Password != "" {
user.Password = s.Password
@ -119,5 +121,6 @@ func NewSettingsForm(r *http.Request) *SettingsForm {
CJKReadingSpeed: int(cjkReadingSpeed),
DefaultHomePage: r.FormValue("default_home_page"),
CategoriesSortingOrder: r.FormValue("categories_sorting_order"),
MarkReadOnView: r.FormValue("mark_read_on_view") == "1",
}
}

View file

@ -43,6 +43,7 @@ func (h *handler) showSettingsPage(w http.ResponseWriter, r *http.Request) {
CJKReadingSpeed: user.CJKReadingSpeed,
DefaultHomePage: user.DefaultHomePage,
CategoriesSortingOrder: user.CategoriesSortingOrder,
MarkReadOnView: user.MarkReadOnView,
}
timezones, err := h.store.Timezones()

View file

@ -69,10 +69,10 @@ document.addEventListener("DOMContentLoaded", function () {
request.execute();
}));
onClick("a[data-original-link]", (event) => {
onClick("a[data-original-link='true']", (event) => {
handleEntryStatus("next", event.target, true);
}, true);
onAuxClick("a[data-original-link]", (event) => {
onAuxClick("a[data-original-link='true']", (event) => {
if (event.button == 1) {
handleEntryStatus("next", event.target, true);
}