diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 8765d89cda..f250adec64 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -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) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VoiceMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VoiceMessageView.kt index e1bf92c5f2..2b829af152 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VoiceMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VoiceMessageView.kt @@ -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) }