From 899fb3d7677716d4e94ebe3ed8fdf022307a90ab Mon Sep 17 00:00:00 2001 From: alansley Date: Sun, 9 Feb 2025 14:00:59 +1100 Subject: [PATCH] Revert "Last send message to blinded recipient identified & code cleaned up" This reverts commit 85c58bd3302111867adbccc035de4232f6ac0286. Sorry, I thought I was on my branch. --- .../v2/messages/VisibleMessageView.kt | 62 +++++-------------- .../securesms/database/MmsSmsColumns.java | 1 + .../sending_receiving/MessageSender.kt | 4 +- 3 files changed, 18 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index d7f8cfc721..33b43e8f10 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -63,7 +63,7 @@ import org.thoughtcrime.securesms.database.model.MmsMessageRecord import org.thoughtcrime.securesms.groups.OpenGroupManager import org.thoughtcrime.securesms.home.UserDetailsBottomSheet import network.loki.messenger.libsession_util.getOrNull -import org.session.libsignal.utilities.Log +import org.thoughtcrime.securesms.dependencies.ConfigFactory import org.thoughtcrime.securesms.util.DateUtils import org.thoughtcrime.securesms.util.disableClipping import org.thoughtcrime.securesms.util.toDp @@ -282,12 +282,6 @@ class VisibleMessageView : FrameLayout { onDoubleTap = { binding.messageContentView.root.onContentDoubleTap?.invoke() } } - private fun showNonDisappearingMessageStatus() { - binding.messageStatusTextView.isVisible = true - binding.messageStatusImageView.isVisible = true - binding.messageStatusImageView.bringToFront() - } - // Method to display or hide the status of a message. // Note: Although most commonly used to display the delivery status of a message, we also use the // message status area to display the disappearing messages state - so in this latter case we'll @@ -332,7 +326,7 @@ class VisibleMessageView : FrameLayout { // ii.) outgoing but NOT scheduled to disappear, or // iii.) outgoing AND scheduled to disappear. - // ----- Case i..) Message is incoming AND scheduled to disappear ----- + // ----- Case i..) Message is incoming and scheduled to disappear ----- if (message.isIncoming && scheduledToDisappear) { // Display the status ('Read') and the show the timer only (no delivery icon) binding.messageStatusTextView.isVisible = true @@ -346,47 +340,21 @@ class VisibleMessageView : FrameLayout { // ----- Case ii.) Message is outgoing but NOT scheduled to disappear ----- if (!scheduledToDisappear) { - // We always show the status of messages which are in the process of being sent - val msgIsSending = message.isOutgoing && !message.isSent - if (msgIsSending) { - showNonDisappearingMessageStatus() - return - } + // If this isn't a disappearing message then we never show the timer - // In the case of messages that we can confirm to be sent then we only show the - // the status of the most recently sent message. - // For non-blinded recipients w - val msgHasBeenSent = message.isOutgoing && message.isSent - if (msgHasBeenSent) { + // If the message has NOT been successfully sent then always show the delivery status text and icon.. + val neitherSentNorRead = !(message.isSent || message.isRead) + if (neitherSentNorRead) { + binding.messageStatusTextView.isVisible = true + binding.messageStatusImageView.isVisible = true + } else { + // ..but if the message HAS been successfully sent or read then only display the delivery status + // text and image if this is the last sent message. val lastSentTimestamp = lastSentTimestampCache.getTimestamp(message.threadId) - if (lastSentTimestamp == null) { - Log.w(TAG, "No last sent timestamp found for message ${message.id} - skipping.") - return - } - - // If we found that this message exactly matches the last sent timestamp in our - // cache then we show the message details and leave. - val gotIdenticalLastSentMatch = lastSentTimestamp == message.timestamp - if (gotIdenticalLastSentMatch) { - showNonDisappearingMessageStatus() - return - } - - // In the case of blinded community messages we must compare against the server's message - // timestamp which is rounded down to the nearest second to find our last outgoing message. - val roundedDownMsgTimestamp = message.timestamp / 1000 * 1000 - val roundedDownCachedTimestamp = lastSentTimestamp / 1000 * 1000 - val gotRoundedLastSentMatch = roundedDownMsgTimestamp == roundedDownCachedTimestamp - if (gotRoundedLastSentMatch) { - // This is the last sent message on a community with a blinded recipient - so show - // the message status and leave. - showNonDisappearingMessageStatus() - return - } else { - // At this point we've exhausted our last sent message matching without identifying a msg, so - // this is NOT the last sent message & we leave with the status details hidden. - return - } + val isLastSent = lastSentTimestamp == message.timestamp + binding.messageStatusTextView.isVisible = isLastSent + binding.messageStatusImageView.isVisible = isLastSent + if (isLastSent) { binding.messageStatusImageView.bringToFront() } } } else // ----- Case iii.) Message is outgoing AND scheduled to disappear ----- diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsColumns.java b/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsColumns.java index 29318bb14d..d6937666fc 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsColumns.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsColumns.java @@ -279,6 +279,7 @@ public interface MmsSmsColumns { return (type & BASE_TYPE_MASK) == FIRST_MISSED_CALL_TYPE; } + public static boolean isGroupUpdate(long type) { return (type & GROUP_UPDATE_BIT) != 0; } diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt index 6f331c5028..efa79e2243 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt @@ -476,8 +476,8 @@ object MessageSender { // pair of modified "markAsSentToCommunity" and "markUnidentifiedInCommunity" methods // to retrieve the local message by thread & message ID rather than timestamp when // handling community messages only so we can tick the delivery status over to 'Sent'. - // Also: Blinded message message timestamps are rounded down to the nearest second. - if (messageIsAddressedToCommunity || destination is Destination.OpenGroupInbox) + // Fixed in: https://optf.atlassian.net/browse/SES-1567 + if (messageIsAddressedToCommunity) { storage.markAsSentToCommunity(message.threadID!!, message.id!!) storage.markUnidentifiedInCommunity(message.threadID!!, message.id!!)