mirror of
https://github.com/miniflux/v2.git
synced 2025-08-21 18:11:09 +00:00
Highlight and sort feeds with unread entries in feeds list
This commit is contained in:
parent
1fc95a83b6
commit
4b2a25eed4
6 changed files with 45 additions and 3 deletions
|
@ -9,12 +9,27 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"miniflux.app/config"
|
"miniflux.app/config"
|
||||||
"miniflux.app/logger"
|
"miniflux.app/logger"
|
||||||
"miniflux.app/model"
|
"miniflux.app/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type byStateAndName struct{ f model.Feeds }
|
||||||
|
|
||||||
|
func (l byStateAndName) Len() int { return len(l.f) }
|
||||||
|
func (l byStateAndName) Swap(i, j int) { l.f[i], l.f[j] = l.f[j], l.f[i] }
|
||||||
|
func (l byStateAndName) Less(i, j int) bool {
|
||||||
|
if l.f[i].UnreadCount > 0 && l.f[j].UnreadCount == 0 {
|
||||||
|
return true
|
||||||
|
} else if l.f[i].UnreadCount == 0 && l.f[j].UnreadCount > 0 {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return l.f[i].Title < l.f[j].Title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FeedExists checks if the given feed exists.
|
// FeedExists checks if the given feed exists.
|
||||||
func (s *Storage) FeedExists(userID, feedID int64) bool {
|
func (s *Storage) FeedExists(userID, feedID int64) bool {
|
||||||
var result bool
|
var result bool
|
||||||
|
@ -121,13 +136,22 @@ func (s *Storage) Feeds(userID int64) (model.Feeds, error) {
|
||||||
return builder.GetFeeds()
|
return builder.GetFeeds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getFeedsSorted(builder *FeedQueryBuilder) (model.Feeds, error) {
|
||||||
|
result, err := builder.GetFeeds()
|
||||||
|
if err == nil {
|
||||||
|
sort.Sort(byStateAndName{result})
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
// FeedsWithCounters returns all feeds of the given user with counters of read and unread entries.
|
// FeedsWithCounters returns all feeds of the given user with counters of read and unread entries.
|
||||||
func (s *Storage) FeedsWithCounters(userID int64) (model.Feeds, error) {
|
func (s *Storage) FeedsWithCounters(userID int64) (model.Feeds, error) {
|
||||||
builder := NewFeedQueryBuilder(s, userID)
|
builder := NewFeedQueryBuilder(s, userID)
|
||||||
builder.WithCounters()
|
builder.WithCounters()
|
||||||
builder.WithOrder(model.DefaultFeedSorting)
|
builder.WithOrder(model.DefaultFeedSorting)
|
||||||
builder.WithDirection(model.DefaultFeedSortingDirection)
|
builder.WithDirection(model.DefaultFeedSortingDirection)
|
||||||
return builder.GetFeeds()
|
return getFeedsSorted(builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FeedsByCategoryWithCounters returns all feeds of the given user/category with counters of read and unread entries.
|
// FeedsByCategoryWithCounters returns all feeds of the given user/category with counters of read and unread entries.
|
||||||
|
@ -137,7 +161,7 @@ func (s *Storage) FeedsByCategoryWithCounters(userID, categoryID int64) (model.F
|
||||||
builder.WithCounters()
|
builder.WithCounters()
|
||||||
builder.WithOrder(model.DefaultFeedSorting)
|
builder.WithOrder(model.DefaultFeedSorting)
|
||||||
builder.WithDirection(model.DefaultFeedSortingDirection)
|
builder.WithDirection(model.DefaultFeedSortingDirection)
|
||||||
return builder.GetFeeds()
|
return getFeedsSorted(builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WeeklyFeedEntryCount returns the weekly entry count for a feed.
|
// WeeklyFeedEntryCount returns the weekly entry count for a feed.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{ define "feed_list" }}
|
{{ define "feed_list" }}
|
||||||
<div class="items">
|
<div class="items">
|
||||||
{{ range .feeds }}
|
{{ range .feeds }}
|
||||||
<article class="item {{ if ne .ParsingErrorCount 0 }}feed-parsing-error{{ end }}">
|
<article class="item {{ if ne .ParsingErrorCount 0 }}feed-parsing-error{{ else if ne .UnreadCount 0 }}feed-has-unread{{ end }}">
|
||||||
<div class="item-header" dir="auto">
|
<div class="item-header" dir="auto">
|
||||||
<span class="item-title">
|
<span class="item-title">
|
||||||
{{ if and (.Icon) (gt .Icon.IconID 0) }}
|
{{ if and (.Icon) (gt .Icon.IconID 0) }}
|
||||||
|
|
|
@ -749,6 +749,12 @@ article.feed-parsing-error {
|
||||||
border-color: #aaa;
|
border-color: #aaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
article.feed-has-unread {
|
||||||
|
background-color: var(--feed-has-unread-background-color);
|
||||||
|
border-style: var(--feed-has-unread-border-style);
|
||||||
|
border-color: var(--feed-has-unread-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
.parsing-error {
|
.parsing-error {
|
||||||
font-size: 0.85em;
|
font-size: 0.85em;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
|
|
|
@ -101,6 +101,9 @@
|
||||||
|
|
||||||
--parsing-error-color: #eee;
|
--parsing-error-color: #eee;
|
||||||
--feed-parsing-error-background-color: #343434;
|
--feed-parsing-error-background-color: #343434;
|
||||||
|
--feed-has-unread-background-color: #1b1a1a;
|
||||||
|
--feed-has-unread-border-style: solid;
|
||||||
|
--feed-has-unread-border-color: rgba(82, 168, 236, 0.6);
|
||||||
|
|
||||||
--keyboard-shortcuts-li-color: #9b9b9b;
|
--keyboard-shortcuts-li-color: #9b9b9b;
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,9 @@
|
||||||
|
|
||||||
--parsing-error-color: #333;
|
--parsing-error-color: #333;
|
||||||
--feed-parsing-error-background-color: #fcf8e3;
|
--feed-parsing-error-background-color: #fcf8e3;
|
||||||
|
--feed-has-unread-background-color: #dfd;
|
||||||
|
--feed-has-unread-border-style: dotted;
|
||||||
|
--feed-has-unread-border-color: var(--entry-header-border-color);
|
||||||
|
|
||||||
--keyboard-shortcuts-li-color: #333;
|
--keyboard-shortcuts-li-color: #333;
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,9 @@
|
||||||
|
|
||||||
--parsing-error-color: #333;
|
--parsing-error-color: #333;
|
||||||
--feed-parsing-error-background-color: #fcf8e3;
|
--feed-parsing-error-background-color: #fcf8e3;
|
||||||
|
--feed-has-unread-background-color: #dfd;
|
||||||
|
--feed-has-unread-border-style: dotted;
|
||||||
|
--feed-has-unread-border-color: var(--entry-header-border-color);
|
||||||
|
|
||||||
--keyboard-shortcuts-li-color: #333;
|
--keyboard-shortcuts-li-color: #333;
|
||||||
|
|
||||||
|
@ -208,6 +211,9 @@
|
||||||
|
|
||||||
--parsing-error-color: #eee;
|
--parsing-error-color: #eee;
|
||||||
--feed-parsing-error-background-color: #343434;
|
--feed-parsing-error-background-color: #343434;
|
||||||
|
--feed-has-unread-background-color: #1b1a1a;
|
||||||
|
--feed-has-unread-border-style: solid;
|
||||||
|
--feed-has-unread-border-color: rgba(82, 168, 236, 0.6);
|
||||||
|
|
||||||
--keyboard-shortcuts-li-color: #9b9b9b;
|
--keyboard-shortcuts-li-color: #9b9b9b;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue