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

add option to hide categories from the global unread list

This commit is contained in:
pennae 2021-06-03 02:39:47 +02:00 committed by fguillot
parent 571d7bf17c
commit 0bcfc81b1f
24 changed files with 109 additions and 30 deletions

View file

@ -37,7 +37,11 @@ func (h *handler) showEditCategoryPage(w http.ResponseWriter, r *http.Request) {
}
categoryForm := form.CategoryForm{
Title: category.Title,
Title: category.Title,
HideGlobally: "",
}
if category.HideGlobally {
categoryForm.HideGlobally = "checked"
}
view.Set("form", categoryForm)

View file

@ -48,7 +48,10 @@ func (h *handler) updateCategory(w http.ResponseWriter, r *http.Request) {
view.Set("countUnread", h.store.CountUnreadEntries(loggedUser.ID))
view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(loggedUser.ID))
categoryRequest := &model.CategoryRequest{Title: categoryForm.Title}
categoryRequest := &model.CategoryRequest{
Title: categoryForm.Title,
HideGlobally: categoryForm.HideGlobally,
}
if validationErr := validator.ValidateCategoryModification(h.store, loggedUser.ID, category.ID, categoryRequest); validationErr != nil {
view.Set("errorMessage", validationErr.TranslationKey)

View file

@ -26,10 +26,11 @@ func (h *handler) updateEntriesStatus(w http.ResponseWriter, r *http.Request) {
return
}
if err := h.store.SetEntriesStatus(request.UserID(r), entriesStatusUpdateRequest.EntryIDs, entriesStatusUpdateRequest.Status); err != nil {
count, err := h.store.SetEntriesStatusCount(request.UserID(r), entriesStatusUpdateRequest.EntryIDs, entriesStatusUpdateRequest.Status)
if err != nil {
json.ServerError(w, r, err)
return
}
json.OK(w, r, "OK")
json.OK(w, r, count)
}

View file

@ -10,12 +10,14 @@ import (
// CategoryForm represents a feed form in the UI
type CategoryForm struct {
Title string
Title string
HideGlobally string
}
// NewCategoryForm returns a new CategoryForm.
func NewCategoryForm(r *http.Request) *CategoryForm {
return &CategoryForm{
Title: r.FormValue("title"),
Title: r.FormValue("title"),
HideGlobally: r.FormValue("hide_globally"),
}
}

View file

@ -206,14 +206,20 @@ function updateEntriesStatus(entryIDs, status, callback) {
let url = document.body.dataset.entriesStatusUrl;
let request = new RequestBuilder(url);
request.withBody({entry_ids: entryIDs, status: status});
request.withCallback(callback);
request.execute();
request.withCallback((resp) => {
resp.json().then(count => {
if (callback) {
callback(resp);
}
if (status === "read") {
decrementUnreadCounter(1);
} else {
incrementUnreadCounter(1);
}
if (status === "read") {
decrementUnreadCounter(count);
} else {
incrementUnreadCounter(count);
}
});
});
request.execute();
}
// Handle save entry from list view and entry view.

View file

@ -34,6 +34,7 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
offset := request.QueryIntParam(r, "offset", 0)
builder := h.store.NewEntryQueryBuilder(user.ID)
builder.WithStatus(model.EntryStatusUnread)
builder.WithGloballyVisible()
countUnread, err := builder.CountEntries()
if err != nil {
html.ServerError(w, r, err)
@ -52,6 +53,7 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
builder.WithDirection(user.EntryDirection)
builder.WithOffset(offset)
builder.WithLimit(user.EntriesPerPage)
builder.WithGloballyVisible()
entries, err := builder.GetEntries()
if err != nil {
html.ServerError(w, r, err)