From: Olaf Wintermann Date: Sun, 16 Nov 2025 08:10:54 +0000 (+0100) Subject: implement moving feeds to another group when a group is deleted X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=fdb43567c6f35a0801e37382944ae51be7944d63;p=rssreader.git implement moving feeds to another group when a group is deleted --- 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 820b312..930ca4f 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt @@ -3,12 +3,7 @@ package de.unixwork.rssreader import com.zaxxer.hikari.HikariConfig import com.zaxxer.hikari.HikariDataSource import de.unixwork.ui.Context -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.IO -import kotlinx.coroutines.launch import java.sql.Connection -import java.sql.DriverManager import java.sql.Statement object Database { @@ -424,6 +419,19 @@ object Database { } } + public fun moveFeedCollections(from: FeedGroup, to: FeedGroup) { + dataSource.connection.use { conn -> + // move + conn.prepareStatement(""" + update feedcollections set group_id = ? where group_id = ? + """.trimIndent()).use { stmt -> + stmt.setInt(1, to.id) + stmt.setInt(2, from.id) + stmt.execute() + } + } + } + public fun getPendingFeeds(defaultInterval: Int) : MutableList { val feeds = mutableListOf() 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 438006f..2939627 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt @@ -136,13 +136,12 @@ class MainWindow() { onClick = { ev -> if(ev.intValue == 4) { sourceList.removeFeedGroup(feedGroup) - if(move!!.booleanValue() && groups!!.selected != null) { - // move and delete - } else { - // delete - GlobalScope.launch(Dispatchers.IO) { - Database.deleteFeedGroup(feedGroup) + GlobalScope.launch(Dispatchers.IO) { + if(move!!.booleanValue() && groups!!.selected != null) { + // move and delete + Database.moveFeedCollections(feedGroup, groups!!.selected) } + Database.deleteFeedGroup(feedGroup) } } ev.`object`.close()