]> uap-core.de Git - rssreader.git/commitdiff
implement reload for feed groups
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 13 Nov 2025 16:33:26 +0000 (17:33 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 13 Nov 2025 16:33:26 +0000 (17:33 +0100)
rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt
rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt

index d264a0219dac11c277887f8cac9dc58cfffbb80f..ea7e136e7f5b9e9fe2ba81ffab8735f4680c0f48 100644 (file)
@@ -369,7 +369,36 @@ object Database {
                 }
             }
         }
+        return feeds
+    }
+
+    public fun getGroupFeeds(group: FeedGroup) : MutableList<Feed> {
+        val feeds = mutableListOf<Feed>()
 
+        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
     }
 
index dc779c91ad37e7c87154ec0b44f4fdac923deb4e..46258bb2e0d9a0793f19c6090b0eaf9658f31ffe 100644 (file)
@@ -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()
                 }
             }