import de.unixwork.ui.kotlin.separator
import de.unixwork.ui.kotlin.setDefaultWindowSize
import de.unixwork.ui.kotlin.splitViewWindow
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
import java.time.LocalDate
import java.time.ZoneId
import java.time.format.DateTimeFormatter
var currentSublistIndex = -1
var currentFeedIndex = -1
+ var buttonCurrentSublistIndex = -1
+ var buttonCurrentFeedIndex = -1
+
val contextMenu = menuBuilder {
menuItem("Reload") {
-
+ if(buttonCurrentFeedIndex >= 0 && buttonCurrentSublistIndex >= 0) {
+ val feed = sourceList.groups[buttonCurrentSublistIndex].feeds[buttonCurrentFeedIndex]
+ SyncJob({ Database.getCollectionFeeds(feed)}).sync() {
+ App.window?.reload()
+ }
+ }
+ contextMenuReset()
}
menuItem("Mark as read") {
-
+ if(buttonCurrentFeedIndex >= 0 && buttonCurrentSublistIndex >= 0) {
+ try {
+ val feed = sourceList.groups[buttonCurrentSublistIndex].feeds[buttonCurrentFeedIndex]
+ feed.unreadItemsCount = 0
+ feed.updateReadStatus(true)
+ if(buttonCurrentSublistIndex == currentSublistIndex && buttonCurrentFeedIndex == currentFeedIndex) {
+ feedList.reloadCurrentFeed()
+ }
+ GlobalScope.launch(Dispatchers.IO) {
+ Database.updateFeedReadState(feed, true)
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ sourceList.feeds.update()
+ }
+ contextMenuReset()
}
separator()
menuItem("Move Up") {
+ contextMenuReset()
}
menuItem("Move Down") {
-
+ contextMenuReset()
}
menuItem("Delete") {
-
+ contextMenuReset()
}
separator()
menuItem("Settings") {
-
+ contextMenuReset()
}
}
} catch (e: Exception) {
e.printStackTrace()
}
+ },
+ onButtonClick = { event ->
+ val evt = event.subListEventData
+ buttonCurrentSublistIndex = evt.sublistIndex
+ buttonCurrentFeedIndex = evt.rowIndex
}
)
{ elm: FeedCollection?, i, sublist ->
window.ui.attach(feedList)
}
+ fun contextMenuReset() {
+ buttonCurrentFeedIndex = -1
+ buttonCurrentSublistIndex = -1
+ }
+
fun reload() {
sourceList.invalidateCache()
sourceList.reloadStatus()