From c1c3624593531b56b81339ae11eda7973f317c1d Mon Sep 17 00:00:00 2001 From: Jebbs Date: Sat, 11 Dec 2021 11:56:14 +0800 Subject: [PATCH] Order disabled feeds at the end of the list --- storage/feed.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/storage/feed.go b/storage/feed.go index 5198ed4b..89b9b0ec 100644 --- a/storage/feed.go +++ b/storage/feed.go @@ -21,17 +21,17 @@ 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].ParsingErrorCount > 0 && l.f[j].ParsingErrorCount == 0 { - return true - } else if l.f[i].ParsingErrorCount == 0 && l.f[j].ParsingErrorCount > 0 { - return false - } else 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 + // disabled test first, since we don't care about errors if disabled + if l.f[i].Disabled != l.f[j].Disabled { + return l.f[j].Disabled } + if l.f[i].ParsingErrorCount != l.f[j].ParsingErrorCount { + return l.f[i].ParsingErrorCount > l.f[j].ParsingErrorCount + } + if l.f[i].UnreadCount != l.f[j].UnreadCount { + return l.f[i].UnreadCount > l.f[j].UnreadCount + } + return l.f[i].Title < l.f[j].Title } // FeedExists checks if the given feed exists.