From bb92b7f98c00cac8dbc3b2651b69ce135bf404f1 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 13 Nov 2025 17:33:26 +0100 Subject: [PATCH] implement reload for feed groups --- .../kotlin/de/unixwork/rssreader/Database.kt | 29 +++++++++++++++++++ .../de/unixwork/rssreader/MainWindow.kt | 11 +++++-- 2 files changed, 37 insertions(+), 3 deletions(-) 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 d264a02..ea7e136 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt @@ -369,7 +369,36 @@ object Database { } } } + return feeds + } + + public fun getGroupFeeds(group: FeedGroup) : MutableList { + val feeds = mutableListOf() + dataSource.connection.use { conn -> + conn.prepareStatement(""" + select f.* from feeds f + inner join feedcollections c on f.feedcollection_id = c.feedcollection_id + where c.group_id = ? + """.trimIndent()).use { stmt -> + stmt.setInt(1, group.id) + stmt.executeQuery().use { rs -> + while(rs.next()) { + val id = rs.getInt("feed_id") + val feedCollectionId = rs.getInt("feedcollection_id") + val url = rs.getString("url") + val authUser = rs.getString("auth_user") + val authPassword = rs.getString("auth_password") + val certPath = rs.getString("certpath") + val feed = Feed(id, feedCollectionId, url) + feed.user = authUser + feed.password = authPassword + feed.certpath = certPath + feeds.add(feed) + } + } + } + } return feeds } 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 dc779c9..46258bb 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt @@ -47,9 +47,14 @@ class MainWindow() { menuItem("Reload") { event -> val evt = event.subListEventData val feedIndex = evt.rowIndex - if(feedIndex >= 0 && evt.sublistIndex >= 0) { - val feed = sourceList.groups[evt.sublistIndex].feeds[feedIndex] - SyncJob({ Database.getCollectionFeeds(feed)}).sync() { + if(evt.sublistIndex >= 0) { + SyncJob({ + if(feedIndex >= 0) { + Database.getCollectionFeeds(sourceList.groups[evt.sublistIndex].feeds[feedIndex]) + } else { + Database.getGroupFeeds(sourceList.groups[evt.sublistIndex]) + } + }).sync() { App.window?.reload() } } -- 2.47.3