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 = uiState.messages,
key = { it.id.toString() + (it.updateDate ?: it.publishDate) },
key = {
it.id.toString() + (it.updateDate ?: it.publishDate) + it.read
},
) { message ->
val isMyMessage = message.creator?.id == uiState.currentUserId
val content = message.content.orEmpty()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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