]> uap-core.de Git - rssreader.git/commitdiff
add markCurrentFeed toolbar item
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 9 Oct 2025 14:35:19 +0000 (16:35 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 9 Oct 2025 14:35:19 +0000 (16:35 +0200)
rss-application/src/main/kotlin/de/unixwork/rssreader/App.kt

index 11bbf6a800dbc7a1c2955d81e5c0d6b5a05119be..784ab8053acf88f8a27ebedb78395b3cdc44fa33 100644 (file)
@@ -50,10 +50,27 @@ object App : Application {
         }
     }
 
+    fun markCurrentFeedAsRead() {
+        if(window?.feedList?.currentFeed != null) {
+            window?.feedList?.currentFeed?.unreadItemsCount = 0
+            window?.feedList?.currentFeed?.items?.forEach { item ->
+                item.isRead = true
+            }
+            window?.feedList?.items?.update()
+            window?.updateCurrentFeedState()
+            GlobalScope.launch(Dispatchers.IO) {
+                Database.updateFeedReadState(window?.feedList?.currentFeed!!, true)
+            }
+        }
+    }
+
     fun initToolbar() {
         toolbarItem(name = "reloadFeed", icon = "view-refresh") { event ->
             syncCurrent()
         }
+        toolbarItem(name = "markCurrentFeed", icon = "checkbox-checked") { event ->
+            markCurrentFeedAsRead()
+        }
 
         toolbarToggleItem(name = "starred", icon = "starred", varname = "starred") { event ->
             setBookmark(event.intValue == 1)
@@ -68,17 +85,7 @@ object App : Application {
             }
             separator()
             menuItem(label = "Mark Current Feed as Read") {
-                if(window?.feedList?.currentFeed != null) {
-                    window?.feedList?.currentFeed?.unreadItemsCount = 0
-                    window?.feedList?.currentFeed?.items?.forEach { item ->
-                        item.isRead = true
-                    }
-                    window?.feedList?.items?.update()
-                    window?.updateCurrentFeedState()
-                    GlobalScope.launch(Dispatchers.IO) {
-                        Database.updateFeedReadState(window?.feedList?.currentFeed!!, true)
-                    }
-                }
+                markCurrentFeedAsRead()
             }
             menuItem(label = "Mark All as Read") {
                 GlobalScope.launch(Dispatchers.IO) {
@@ -98,6 +105,7 @@ object App : Application {
         }
 
         addToolbarDefault("reloadFeed", ToolbarPosition.LEFT)
+        addToolbarDefault("markCurrentFeed", ToolbarPosition.LEFT)
         addToolbarDefault("starred", ToolbarPosition.RIGHTPANEL_LEFT)
     }