Display news item count in stash view

This commit is contained in:
Nicolas Martin 2020-10-25 04:57:12 +01:00 committed by Christian Rocha
parent 7fb4a43474
commit 4782b99154

View file

@ -851,9 +851,10 @@ func stashHeaderView(m stashModel) string {
localItems := m.countMarkdowns(localMarkdown)
stashedItems := m.countMarkdowns(stashedMarkdown) + m.countMarkdowns(convertedMarkdown)
newsItems := m.countMarkdowns(newsMarkdown)
// Loading's finished and all we have is news.
if !loading && localItems == 0 && stashedItems == 0 {
if !loading && localItems == 0 && stashedItems == 0 && newsItems == 0 {
if m.stashedOnly() {
return common.Subtle("No stashed markdown files found.") + maybeOffline
} else {
@ -874,6 +875,18 @@ func stashHeaderView(m stashModel) string {
si := common.Subtle(fmt.Sprintf("%d Stashed", stashedItems))
s += fmt.Sprintf("%s%s", divider, si)
}
if newsItems > 0 {
var divider string
if localItems > 0 || stashedItems > 0 {
divider = dividerDot
}
si := common.Subtle(fmt.Sprintf("%d News", newsItems))
if newsItems == 1 {
si = common.Subtle(fmt.Sprintf("%d New", newsItems))
}
s += fmt.Sprintf("%s%s", divider, si)
}
return common.Subtle(s) + maybeOffline
}