fun markCurrentFeedAsRead() {
if(window?.feedList?.currentFeed != null) {
- window?.feedList?.currentFeed?.unreadItemsCount = 0
- window?.feedList?.currentFeed?.items?.forEach { item ->
- item.isRead = true
+ if(window?.feedList?.currentFeed?.isGroup == false) {
+ // normal feedcollection
+ window?.feedList?.currentFeed?.unreadItemsCount = 0
+ window?.feedList?.currentFeed?.items?.forEach { item ->
+ item.isRead = true
+ }
+ GlobalScope.launch(Dispatchers.IO) {
+ Database.updateFeedReadState(window?.feedList?.currentFeed!!, true)
+ }
+ } else {
+ // feedgroup
+ window?.feedList?.currentFeed?.items?.forEach { item ->
+ item.isRead = true
+ item.collection?.unreadItemsCount = 0
+ }
+ GlobalScope.launch(Dispatchers.IO) {
+ Database.updateFeedGroupReadState(window?.feedList?.currentFeed!!.id, true)
+ }
}
window?.feedList?.items?.update()
window?.updateCurrentFeedState()
- GlobalScope.launch(Dispatchers.IO) {
- Database.updateFeedReadState(window?.feedList?.currentFeed!!, true)
- }
}
}
}
}
+ public fun updateFeedGroupReadState(feedGroupId: Int, read: Boolean) {
+ dataSource.connection.use { conn ->
+ conn.prepareStatement("""
+ update items set is_read = ? where feed_id in (
+ select feed_id from feeds f
+ inner join feedcollections c on f.feedcollection_id = c.feedcollection_id
+ where group_id = ?)
+ """.trimIndent()).use { stmt ->
+ stmt.setBoolean(1, read)
+ stmt.setInt(2, feedGroupId)
+ stmt.execute()
+ }
+ }
+ }
+
public fun updateAllItems(read: Boolean) {
dataSource.connection.use { conn ->
conn.prepareStatement("""
}
fun updateCurrentFeedState() {
- if(currentFeedIndex >= 0 && currentSublistIndex >= 0) {
- sourceList.groups[currentSublistIndex].feeds.update(currentFeedIndex)
+ if(currentSublistIndex >= 0) {
+ if(currentFeedIndex >= 0) {
+ // feedcollection selected
+ sourceList.groups[currentSublistIndex].feeds.update(currentFeedIndex)
+ } else {
+ // feedgroup selected
+ sourceList.groups[currentSublistIndex].feeds.update()
+ }
}
}