Fixed a couple of bugs with the highlighting

This commit is contained in:
Morgan Pretty 2023-06-13 09:06:26 +10:00
parent da02d385d1
commit ba7a759905
2 changed files with 8 additions and 4 deletions

View File

@ -501,11 +501,15 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
if (cursor != null) {
val messageTimestamp = messageToScrollTimestamp.getAndSet(-1)
val author = messageToScrollAuthor.getAndSet(null)
var initialUnreadCount = 0
// Update the unreadCount value to be loaded from the database since we got a new message
if (firstLoad.get() || oldCount != newCount) {
// Update the unreadCount value to be loaded from the database since we got a new message
unreadCount = mmsSmsDb.getUnreadCount(viewModel.threadId)
// Update the unreadCount value to be loaded from the database since we got a new
// message (we need to store it in a local variable as it can get overwritten on
// another thread before the 'firstLoad.getAndSet(false)' case below)
initialUnreadCount = mmsSmsDb.getUnreadCount(viewModel.threadId)
unreadCount = initialUnreadCount
updateUnreadCountIndicator()
}
@ -518,7 +522,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
val lastSeenItemPosition = scrollToFirstUnreadMessageIfNeeded(true)
handleRecyclerViewScrolled()
if (lastSeenItemPosition != null) {
if (initialUnreadCount > 0 && lastSeenItemPosition != null) {
forceHighlightNextLoad.set(lastSeenItemPosition)
}
}

View File

@ -92,7 +92,7 @@ class VoiceMessageView : RelativeLayout, AudioSlidePlayer.Listener {
if (progress == 1.0) {
togglePlayback()
handleProgressChanged(0.0)
delegate?.playVoiceMessageAtIndexIfPossible(indexInAdapter - 1)
delegate?.playVoiceMessageAtIndexIfPossible(indexInAdapter + 1)
} else {
handleProgressChanged(progress)
}