Quality checks/fixes

This commit is contained in:
Jenna Vassar
2026-04-29 18:13:38 -07:00
parent 2579e68edc
commit ef7cb35de8
3 changed files with 15 additions and 12 deletions
@@ -296,11 +296,7 @@ class TimelinePresenter(
markerIdx = i
break
}
if (item is TimelineItem.Event &&
!item.isMine &&
item.origin != TimelineItemEventOrigin.PAGINATION &&
item.content.isMessageContent()
) {
if (item is TimelineItem.Event && item.isCountableNewMessage()) {
unread++
}
}
@@ -464,11 +460,7 @@ class TimelinePresenter(
var delta = 0
for (item in timelineItems) {
if (item.identifier() == prevMostRecentItemIdValue) break
if (item is TimelineItem.Event &&
item.origin != TimelineItemEventOrigin.PAGINATION &&
!item.isMine &&
item.content.isMessageContent()
) {
if (item is TimelineItem.Event && item.isCountableNewMessage()) {
delta++
}
}
@@ -519,6 +511,16 @@ private fun FocusRequestState.onFocusEventRender(): FocusRequestState {
}
}
/**
* Whether this event should be counted toward the unread / new-message badges: a user-facing
* message from someone other than the local user, that wasn't pulled in via back-pagination.
*/
private fun TimelineItem.Event.isCountableNewMessage(): Boolean {
return !isMine &&
origin != TimelineItemEventOrigin.PAGINATION &&
content.isMessageContent()
}
// Workaround for not having the server names available, get possible server names from the user ids of the room members
private fun calculateServerNamesForRoom(room: JoinedRoom): List<String> {
// If we have no room members, return right ahead
@@ -598,7 +598,7 @@ internal fun TimelineViewWithReadMarkerPreview() = ElementPreview {
@PreviewsDayNight
@Composable
internal fun TimelineViewWithReadMarkerDotBadgesPreview() = ElementPreview {
TimelineViewWithReadMarker(unreadMessagesCount = 47, newMessagesCount = 99)
TimelineViewWithReadMarker(unreadMessagesCount = 47, newMessagesCount = 0)
}
@PreviewsDayNight
@@ -139,7 +139,8 @@ enum class FeatureFlags(
JumpToUnread(
key = "feature.jump_to_unread",
title = "Jump to unread messages",
description = "Show a button to jump to the read marker, plus a count badge on the scroll-to-bottom button when new messages arrive while scrolled away.",
description = "Show a button to jump to the read marker, plus a count badge on the scroll-to-bottom button " +
"when new messages arrive while scrolled away.",
defaultValue = { false },
isFinished = false,
),