pos INT default 0,
name VARCHAR,
update_interval INT,
- auto_mark_read BOOLEAN DEFAULT FALSE
+ item_state_mode INT DEFAULT 0
)
""".trimIndent())
f.feedcollection_id,
f.name as feed_name,
f.update_interval,
- f.auto_mark_read,
+ f.item_state_mode,
c.unread_count
from groups g
left join feedcollections f on g.group_id = f.group_id
val feedId = rs.getInt("feedcollection_id")
val feedName = rs.getString("feed_name")
val updateInterval = rs.getLong("update_interval")
- val autoMarkRead = rs.getBoolean("auto_mark_read")
+ val itemStateMode = rs.getInt("item_state_mode")
val unreadCount = rs.getInt("unread_count")
if(currentGroup == null || currentGroup.id != groupId) {
if(feedId != null && feedName != null) {
val feed = FeedCollection(feedId, feedName)
feed.updateInterval = updateInterval
- feed.autoMarkRead = autoMarkRead
+ feed.itemStateMode = itemStateMode
feed.unreadItemsCount = unreadCount
currentGroup.feeds.add(feed)
}
password: String? = null,
cert: String? = null,
updateInterval: Long = 0,
- autoMarkRead: Boolean = false) : FeedCollection
+ itemStateMode: Int = 0) : FeedCollection
{
var feedcollectionId = -1
val connection = dataSource.connection
connection.prepareStatement("""
- insert into feedcollections (group_id, pos, name, update_interval, auto_mark_read) select ?, coalesce(max(pos), 0)+1, ?, ?, ? from groups
+ insert into feedcollections (group_id, pos, name, update_interval, item_state_mode) 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.setInt(4, itemStateMode)
stmt.execute()
stmt.generatedKeys.use { rs ->
if(rs.next()) {
}
}
}
+
+ public fun updateFeedReadState(feedCollection: FeedCollection, read: Boolean) {
+ dataSource.connection.use { conn ->
+ conn.prepareStatement("""
+ update items set is_read = ? where feed_id in (select feed_id from feedcollections where feedcollection_id = ?)
+ """.trimIndent()).use { stmt ->
+ stmt.setBoolean(1, read)
+ stmt.setInt(2, feedCollection.id)
+ stmt.execute()
+ }
+ }
+ }
}
feed?.let {
println("feed: ${feed.name}")
feedList.loadFeed(feed)
+ sourceList.feeds.update()
}
} catch (e: Exception) {
e.printStackTrace()
{ elm: FeedCollection ->
val item = SubListItem()
item.label = elm.name
- if(elm.unreadItemsCount > 0) {
+ if(elm.unreadItemsCount > 0 && elm.itemStateMode != 2) {
item.badge = elm.unreadItemsCount.toString()
}
item
var ret = false
// only highlight unread items if the feed(collection) is configured
// to have individual read states
- if(feedList.currentFeed?.autoMarkRead == false) {
+ if(feedList.currentFeed?.itemStateMode == 0) {
// col == -1: style for the entire row
// highlight unread items
if(col == -1 && !elm.isRead) {
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
+ var itemStateMode = readstatus?.selectedIndex ?: 0
+ if(itemStateMode < 0 || itemStateMode > 2) {
+ itemStateMode = 0
+ }
println("groupSel: ${groups?.selectedIndex}, feedName: $feedName, urlStr: $urlStr")
parent?.let {
try {
password.toString(),
cert.toString(),
0, // TODO
- automarkread
+ itemStateMode
)
parent.feeds.update()
readstatus.add("Mark items individually")
readstatus.add("Mark entire feed when opened")
+ readstatus.add("Don't show number of unread items")
// UI
grid(