fix: include post read property in item keys (#241)

This commit is contained in:
Dieguitux 2025-01-09 23:16:30 +01:00 committed by GitHub
parent 4e7dbedb49
commit b97351b011
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 31 additions and 17 deletions

View File

@ -276,7 +276,9 @@ class InboxChatScreen(
} }
items( items(
items = uiState.messages, items = uiState.messages,
key = { it.id.toString() + (it.updateDate ?: it.publishDate) }, key = {
it.id.toString() + (it.updateDate ?: it.publishDate) + it.read
},
) { message -> ) { message ->
val isMyMessage = message.creator?.id == uiState.currentUserId val isMyMessage = message.creator?.id == uiState.currentUserId
val content = message.content.orEmpty() val content = message.content.orEmpty()

View File

@ -821,7 +821,9 @@ class CommunityDetailScreen(
} }
items( items(
items = uiState.posts, items = uiState.posts,
key = { it.id.toString() + (it.updateDate ?: it.publishDate) }, key = {
it.id.toString() + (it.updateDate ?: it.publishDate) + it.read
},
) { post -> ) { post ->
LaunchedEffect(post.id) { LaunchedEffect(post.id) {
if (settings.markAsReadWhileScrolling && !post.read) { if (settings.markAsReadWhileScrolling && !post.read) {

View File

@ -369,7 +369,7 @@ class FilteredContentsScreen(
items( items(
items = uiState.posts, items = uiState.posts,
key = { key = {
it.id.toString() + (it.updateDate ?: it.publishDate) it.id.toString() + (it.updateDate ?: it.publishDate) + it.read
}, },
) { post -> ) { post ->
@ -708,8 +708,8 @@ class FilteredContentsScreen(
} }
} }
items( items(
uiState.comments, items = uiState.comments,
{ it.id.toString() + (it.updateDate ?: it.publishDate) }, key = { it.id.toString() + (it.updateDate ?: it.publishDate) },
) { comment -> ) { comment ->
@Composable @Composable

View File

@ -110,7 +110,9 @@ class InboxMessagesScreen : Tab {
items( items(
items = uiState.chats, items = uiState.chats,
key = { key = {
it.id.toString() + (it.updateDate ?: it.publishDate) + it.read + uiState.unreadOnly it.id.toString() + (
it.updateDate ?: it.publishDate
) + it.read + uiState.unreadOnly
}, },
) { chat -> ) { chat ->
ChatCard( ChatCard(

View File

@ -281,7 +281,9 @@ class MultiCommunityScreen(
} }
items( items(
items = uiState.posts, items = uiState.posts,
key = { it.id.toString() + (it.updateDate ?: it.publishDate) }, key = {
it.id.toString() + (it.updateDate ?: it.publishDate) + it.read
},
) { post -> ) { post ->
LaunchedEffect(post.id) { LaunchedEffect(post.id) {
if (settings.markAsReadWhileScrolling && !post.read) { if (settings.markAsReadWhileScrolling && !post.read) {

View File

@ -276,7 +276,9 @@ object ProfileLoggedScreen : Tab {
} }
items( items(
items = uiState.posts, items = uiState.posts,
key = { it.id.toString() + (it.updateDate ?: it.publishDate) }, key = {
it.id.toString() + (it.updateDate ?: it.publishDate) + it.read
},
) { post -> ) { post ->
PostCard( PostCard(
post = post, post = post,

View File

@ -360,9 +360,8 @@ class PostListScreen : Screen {
// isLogged is added to the key to force swipe action refresh // isLogged is added to the key to force swipe action refresh
key = { key = {
it.id.toString() + ( it.id.toString() + (
it.updateDate it.updateDate ?: it.publishDate
?: it.publishDate ) + it.read + uiState.isLogged
) + uiState.isLogged
}, },
) { post -> ) { post ->
LaunchedEffect(post.id) { LaunchedEffect(post.id) {

View File

@ -233,8 +233,7 @@ class ReportListScreen(
items = uiState.postReports, items = uiState.postReports,
key = { key = {
it.id.toString() + ( it.id.toString() + (
it.updateDate it.updateDate ?: it.publishDate
?: it.publishDate
) + it.resolved + uiState.unresolvedOnly ) + it.resolved + uiState.unresolvedOnly
}, },
) { report -> ) { report ->
@ -346,8 +345,12 @@ class ReportListScreen(
} }
} }
items( items(
uiState.commentReports, items = uiState.commentReports,
{ it.id.toString() + (it.updateDate ?: it.publishDate) }, key = {
it.id.toString() + (
it.updateDate ?: it.publishDate
) + it.resolved
},
) { report -> ) { report ->
SwipeActionCard( SwipeActionCard(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),

View File

@ -544,8 +544,10 @@ class UserDetailScreen(
} }
} }
items( items(
uiState.posts, items = uiState.posts,
{ it.id.toString() + (it.updateDate ?: it.publishDate) }, key = {
it.id.toString() + (it.updateDate ?: it.publishDate) + it.read
},
) { post -> ) { post ->
@Composable @Composable