From: Olaf Wintermann Date: Wed, 26 Nov 2025 17:38:33 +0000 (+0100) Subject: implement loading a whole feed group in the feed list X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=1b6c78cd3089e419bc0028a237941b4dcd56b2d6;p=rssreader.git implement loading a whole feed group in the feed list --- diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt index 930ca4f..3ea05e9 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt @@ -303,6 +303,7 @@ object Database { item.feedUrl = rs.getString("URL") item.isRead = rs.getBoolean("is_read") item.isBookmark = rs.getBoolean("is_bookmarked") + item.collection = feedCollection items.add(item) } } diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedCollection.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedCollection.kt index 3362279..7108d9f 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedCollection.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedCollection.kt @@ -14,6 +14,10 @@ class FeedCollection(id: Int, name: String) { var itemsLoaded = false var itemsLoading = false + // Is this FeedCollection actually a FeedGroup? + // In that case, id is the FeedGroup id + var isGroup = false + fun updateReadStatus(isRead: Boolean) { items.forEach { it.isRead = isRead } } diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedList.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedList.kt index 3873069..d963390 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedList.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedList.kt @@ -77,6 +77,48 @@ class FeedList(window: MainWindow) : Document() { items.update() } + fun loadFeedGroup(group: FeedGroup) { + var load = false + group.feeds.forEach { feed -> + if(!feed.itemsLoaded) { + load = true + feed.itemsLoading = true + } + } + + val collection = FeedCollection(group.id, "") + collection.isGroup = true + + showFeed = collection + if(load) { + GlobalScope.launch(Dispatchers.IO) { + group.feeds.forEach { feed -> + feed.items = Database.getItems(feed, 10000) + feed.itemsLoaded = true + } + GlobalScope.launch(ToolkitDispatcher) { + group.feeds.forEach { feed -> + feed.itemsLoading = false + } + if(showFeed == collection) { + loadFeedGroup(group) + } + } + } + return + } + + group.feeds.forEach { feed -> + feed.items.forEach { item -> + collection.items.add(item) + } + } + collection.items.sortByDescending { it.pubDate } + collection.itemsLoaded = true + + loadFeed(collection) + } + fun reloadCurrentFeed() { currentFeed?.let { loadFeed(it) } } diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/Item.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/Item.kt index e4d4228..30431fa 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/Item.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/Item.kt @@ -22,6 +22,8 @@ class Item(id: Int) { var feedName: String? = null var feedUrl: String? = null + var collection: FeedCollection? = null + fun getContent(): Content { contentHtml?.let { return Content(it, "text/html") diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt index 2939627..d01738d 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt @@ -185,6 +185,10 @@ class MainWindow() { currentSublistIndex = evt.sublistIndex currentFeedIndex = evt.rowIndex if(evt.rowIndex == -1) { + val group = sourceList.groups[evt.sublistIndex] + group?.let { + feedList.loadFeedGroup(it) + } return@sourcelist } try {