]> uap-core.de Git - rssreader.git/commitdiff
extend new feed dialog, allow specification of read status updates (auto_mark_read)
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 30 Aug 2025 06:56:40 +0000 (08:56 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 30 Aug 2025 06:56:40 +0000 (08:56 +0200)
rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt
rss-application/src/main/kotlin/de/unixwork/rssreader/MainWindow.kt

index 204dae277d62c04213831da0605d55855ac88f91..ef3d368b0cf496932e54ec6a0e72419d4b0fc013 100644 (file)
@@ -164,15 +164,19 @@ object Database {
         uris: Collection<String>,
         user: String? = null,
         password: String? = null,
-        cert: String? = null) : FeedCollection
+        cert: String? = null,
+        updateInterval: Long = 0,
+        autoMarkRead: Boolean = false) : FeedCollection
     {
         var feedcollectionId = -1
         val connection = dataSource.connection
         connection.prepareStatement("""
-            insert into feedcollections (group_id, pos, name) select ?, coalesce(max(pos), 0)+1, ? from groups
+            insert into feedcollections (group_id, pos, name, update_interval, auto_mark_read) select ?, coalesce(max(pos), 0)+1, ?, ?, ? from groups
         """.trimIndent(), Statement.RETURN_GENERATED_KEYS).use { stmt ->
             stmt.setInt(1, parent.id)
             stmt.setString(2, name)
+            stmt.setLong(3, updateInterval)
+            stmt.setBoolean(4, autoMarkRead)
             stmt.execute()
             stmt.generatedKeys.use { rs ->
                 if(rs.next()) {
index 27f49c2011b0a4cdef7f9aa3d7c6d1da7dc709c1..be8be02389d21519f976be5b3469d822a82f6bcf 100644 (file)
@@ -4,6 +4,7 @@ import de.unixwork.ui.ColumnType
 import de.unixwork.ui.SubListItem
 import de.unixwork.ui.TabViewType
 import de.unixwork.ui.TableModel
+import de.unixwork.ui.UiInteger
 import de.unixwork.ui.UiList
 import de.unixwork.ui.UiString
 import de.unixwork.ui.UiText
@@ -133,6 +134,7 @@ class MainWindow {
         var user: UiString? = null
         var password: UiString? = null
         var cert: UiString? = null
+        var readstatus: UiList<String>? = null
 
         val w = dialogWindow(
             parent = window.ui,
@@ -150,10 +152,22 @@ class MainWindow {
                     val feedName = name.toString()
                     val urlStr = urls.toString()
                     val uris = urlStr.split("\n").map { it.trim() }.filter { it.isNotBlank() }
+                    val readStatus = readstatus?.selectedIndex
+                    val automarkread = readStatus == 1
                     println("groupSel: ${groups?.selectedIndex}, feedName: $feedName, urlStr: $urlStr")
                     parent?.let {
                         try {
-                            val feedCol = Database.newFeeds(it, feedName, uris, user.toString(), password.toString(), cert.toString())
+                            val feedCol = Database.newFeeds(
+                                it,
+                                feedName,
+                                uris,
+                                user.toString(),
+                                password.toString(),
+                                cert.toString(),
+                                0, // TODO
+                                automarkread
+                            )
+
                             parent.feeds.update()
                         } catch (e: Exception) {
                             e.printStackTrace()
@@ -167,12 +181,16 @@ class MainWindow {
             groups = ui.list<FeedGroup>()
             name = ui.string()
             urls = ui.text()
+            readstatus = ui.list()
             user = ui.string()
             password = ui.string()
             cert = ui.string()
 
             groups.addAll(sourceList.groups)
 
+            readstatus.add("Mark items individually")
+            readstatus.add("Mark entire feed when opened")
+
             // UI
             grid(
                 margin = 12,
@@ -196,6 +214,12 @@ class MainWindow {
                     rlabel("URLs", overrideDefaults = true, hfill = true) // overrideDefaults for disabling default vfill
                     textarea(value = urls, hexpand = true, vexpand = true, vfill = true, colspan = 2)
                 }
+                row {
+                    rlabel("Read Status", hfill = true)
+                    dropdown<String>(value = readstatus, hfill = true, colspan = 2) { elm, col ->
+                        elm
+                    }
+                }
 
                 row {
                     rlabel("User")