fix: maybe fix the last seen issues

This commit is contained in:
0x330a 2023-07-10 15:53:00 +10:00
parent 9cdacf7244
commit 230b1acdf2
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
4 changed files with 10 additions and 12 deletions

View File

@ -512,7 +512,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
if (cursor != null) {
val messageTimestamp = messageToScrollTimestamp.getAndSet(-1)
val author = messageToScrollAuthor.getAndSet(null)
var initialUnreadCount = 0
val initialUnreadCount: Int
// Update the unreadCount value to be loaded from the database since we got a new message
if (firstLoad.get() || oldCount != newCount) {
@ -525,7 +525,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
}
if (author != null && messageTimestamp >= 0) {
jumpToMessage(author, messageTimestamp, true, null)
jumpToMessage(author, messageTimestamp, firstLoad.get(), null)
}
else if (firstLoad.getAndSet(false)) {
scrollToFirstUnreadMessageIfNeeded(true)
@ -734,7 +734,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
}
}
private fun scrollToFirstUnreadMessageIfNeeded(isFirstLoad: Boolean = false, shouldHighlight: Boolean = false): Int? {
private fun scrollToFirstUnreadMessageIfNeeded(isFirstLoad: Boolean = false, shouldHighlight: Boolean = false): Int {
val lastSeenTimestamp = threadDb.getLastSeenAndHasSent(viewModel.threadId).first()
val lastSeenItemPosition = adapter.findLastSeenItemPosition(lastSeenTimestamp) ?: return -1

View File

@ -31,12 +31,13 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
import org.thoughtcrime.securesms.mms.GlideRequests
import org.thoughtcrime.securesms.preferences.PrivacySettingsActivity
import java.util.concurrent.atomic.AtomicLong
import kotlin.math.min
class ConversationAdapter(
context: Context,
cursor: Cursor,
private val originalLastSeen: Long,
originalLastSeen: Long,
private val isReversed: Boolean,
private val onItemPress: (MessageRecord, Int, VisibleMessageView, MotionEvent) -> Unit,
private val onItemSwipeToReply: (MessageRecord, Int) -> Unit,
@ -55,6 +56,8 @@ class ConversationAdapter(
private val updateQueue = Channel<String>(1024, onBufferOverflow = BufferOverflow.DROP_OLDEST)
private val contactCache = SparseArray<Contact>(100)
private val contactLoadedCache = SparseBooleanArray(100)
private val lastSeen = AtomicLong(originalLastSeen)
init {
lifecycleCoroutineScope.launch(IO) {
while (isActive) {
@ -131,7 +134,7 @@ class ConversationAdapter(
searchQuery,
contact,
senderId,
originalLastSeen,
lastSeen.get(),
visibleMessageViewDelegate,
onAttachmentNeedsDownload
)

View File

@ -127,7 +127,7 @@ class VisibleMessageView : LinearLayout {
searchQuery: String?,
contact: Contact?,
senderSessionID: String,
originalLastSeen: Long,
lastSeen: Long,
delegate: VisibleMessageViewDelegate?,
onAttachmentNeedsDownload: (Long, Long) -> Unit
) {
@ -195,7 +195,7 @@ class VisibleMessageView : LinearLayout {
if (thread.isOpenGroupRecipient) ContactContext.OPEN_GROUP else ContactContext.REGULAR
binding.senderNameTextView.text = contact?.displayName(contactContext) ?: senderSessionID
// Unread marker
binding.unreadMarkerContainer.isVisible = message.timestamp > originalLastSeen && (previous == null || previous.timestamp <= originalLastSeen)
binding.unreadMarkerContainer.isVisible = lastSeen != -1L && message.timestamp > lastSeen && (previous == null || previous.timestamp <= lastSeen) && !message.isOutgoing
// Date break
val showDateBreak = isStartOfMessageCluster || snIsSelected
binding.dateBreakTextView.text = if (showDateBreak) DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), message.timestamp) else null

View File

@ -132,11 +132,6 @@ object ConfigurationMessageUtilities {
if (storage.isPinned(ownThreadId)) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE
else ConfigBase.PRIORITY_HIDDEN
)
if (ownThreadId != null) {
// have NTS thread
val ntsPinned = storage.isPinned(ownThreadId)
profile.setNtsPriority(if (ntsPinned) 1 else 0) // TODO: implement the pinning priority here in future
}
val dump = profile.dump()
profile.free()
return dump