mirror of https://github.com/readrops/Readrops.git
Fix regression in TimelineTab: items wouldn't be updated without disappearing from the screen
This commit is contained in:
parent
c6eed0eabd
commit
e9cd681b11
|
@ -1,6 +1,5 @@
|
|||
package com.readrops.app.timelime
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
|
@ -54,7 +53,7 @@ fun RegularTimelineItem(
|
|||
modifier: Modifier = Modifier
|
||||
) {
|
||||
TimelineItemContainer(
|
||||
isRead = itemWithFeed.item.isRead,
|
||||
isRead = itemWithFeed.isRead,
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
) {
|
||||
|
@ -68,7 +67,7 @@ fun RegularTimelineItem(
|
|||
folderName = itemWithFeed.folder?.name,
|
||||
date = itemWithFeed.item.pubDate!!,
|
||||
duration = itemWithFeed.item.readTime,
|
||||
isStarred = itemWithFeed.item.isStarred,
|
||||
isStarred = itemWithFeed.isStarred,
|
||||
onFavorite = onFavorite,
|
||||
onShare = onShare
|
||||
)
|
||||
|
@ -100,6 +99,7 @@ fun CompactTimelineItem(
|
|||
|
||||
Surface(
|
||||
color = MaterialTheme.colorScheme.surfaceVariant,
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.drawBehind {
|
||||
|
@ -107,8 +107,7 @@ fun CompactTimelineItem(
|
|||
// so we draw a rect with the current screen background color behind the card but in front of the dismiss background
|
||||
drawRect(containerColor)
|
||||
}
|
||||
.alpha(if (itemWithFeed.item.isRead) readAlpha else 1f)
|
||||
.clickable { onClick() }
|
||||
.alpha(if (itemWithFeed.isRead) readAlpha else 1f)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(
|
||||
|
@ -126,7 +125,7 @@ fun CompactTimelineItem(
|
|||
onShare = onShare,
|
||||
date = itemWithFeed.item.pubDate!!,
|
||||
duration = itemWithFeed.item.readTime,
|
||||
isStarred = itemWithFeed.item.isStarred,
|
||||
isStarred = itemWithFeed.isStarred,
|
||||
displayActions = false
|
||||
)
|
||||
|
||||
|
@ -161,7 +160,7 @@ fun LargeTimelineItem(
|
|||
)
|
||||
} else {
|
||||
TimelineItemContainer(
|
||||
isRead = itemWithFeed.item.isRead,
|
||||
isRead = itemWithFeed.isRead,
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
) {
|
||||
|
@ -176,7 +175,7 @@ fun LargeTimelineItem(
|
|||
folderName = itemWithFeed.folder?.name,
|
||||
date = itemWithFeed.item.pubDate!!,
|
||||
duration = itemWithFeed.item.readTime,
|
||||
isStarred = itemWithFeed.item.isStarred,
|
||||
isStarred = itemWithFeed.isStarred,
|
||||
onFavorite = onFavorite,
|
||||
onShare = onShare
|
||||
)
|
||||
|
@ -238,6 +237,7 @@ fun TimelineItemContainer(
|
|||
val containerColor = MaterialTheme.colorScheme.background
|
||||
|
||||
Card(
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
.padding(padding)
|
||||
.fillMaxWidth()
|
||||
|
@ -250,7 +250,6 @@ fun TimelineItemContainer(
|
|||
)
|
||||
}
|
||||
.alpha(if (isRead) readAlpha else 1f)
|
||||
.clickable { onClick() }
|
||||
) {
|
||||
content()
|
||||
}
|
||||
|
|
|
@ -13,5 +13,11 @@ data class ItemWithFeed(
|
|||
@ColumnInfo(name = "color") @ColorInt val color: Int,
|
||||
@ColumnInfo(name = "icon_url") val feedIconUrl: String?,
|
||||
@ColumnInfo(name = "siteUrl") val websiteUrl: String?,
|
||||
@Embedded(prefix = "folder_") val folder: Folder?
|
||||
@Embedded(prefix = "folder_") val folder: Folder?,
|
||||
// duplicates of Item.isRead and Item.isStarred
|
||||
// this is a workaround to make the UI refresh itself when updating read/star state
|
||||
// as since kotlin 2.0.20 it wouldn't work anymore, because of Item properties mutability
|
||||
// TODO see how to resolve this by improving Item immutability
|
||||
@ColumnInfo(name = "is_starred") val isStarred: Boolean = false,
|
||||
@ColumnInfo(name = "is_read") val isRead: Boolean = false
|
||||
)
|
|
@ -29,11 +29,13 @@ object ItemsQueryBuilder {
|
|||
)
|
||||
|
||||
private val SEPARATE_STATE_COLUMNS = arrayOf(
|
||||
"case When ItemState.remote_id is NULL Or ItemState.read = 1 Then 1 else 0 End is_read",
|
||||
"case When ItemState.remote_id is NULL Or ItemState.read = 1 Then 1 else 0 End read",
|
||||
"case When ItemState.starred = 1 Then 1 else 0 End is_starred",
|
||||
"case When ItemState.starred = 1 Then 1 else 0 End starred"
|
||||
)
|
||||
|
||||
private val OTHER_COLUMNS = arrayOf("read", "starred")
|
||||
private val OTHER_COLUMNS = arrayOf("read AS is_read", "read", "starred AS is_starred", "starred")
|
||||
|
||||
private val SELECT_ALL_JOIN = """Item INNER JOIN Feed on Item.feed_id = Feed.id
|
||||
LEFT JOIN Folder on Feed.folder_id = Folder.id """.trimIndent()
|
||||
|
|
Loading…
Reference in New Issue