From 90d7064c18d0d95cbeb1f3fd04831fb8d36e2d0c Mon Sep 17 00:00:00 2001 From: Al Lansley Date: Thu, 15 Aug 2024 12:13:30 +1000 Subject: [PATCH] Fixed issue where new closed groups would display a timestamp instead of the 'groupNoMessages' text --- .../securesms/conversation/v2/ConversationActivityV2.kt | 9 ++++++++- .../java/org/thoughtcrime/securesms/database/Storage.kt | 6 +++++- .../sending_receiving/MessageSenderClosedGroupHandler.kt | 5 ++++- 3 files changed, 17 insertions(+), 3 deletions(-) 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 b5553a1157..a9e5883e7b 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 @@ -1096,6 +1096,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe val blindedRecipient = viewModel.blindedRecipient val openGroup = viewModel.openGroup + val isClosedGroup = recipient.isGroupRecipient + // Get the correct placeholder text for this type of empty conversation val isNoteToSelf = recipient.isLocalNumber val txtCS: CharSequence = when { @@ -1115,12 +1117,17 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe .format() } - else -> { + recipient.isGroupRecipient -> { // If this is a group or community that we CAN send messages to Phrase.from(applicationContext, R.string.groupNoMessages) .put(GROUP_NAME_KEY, recipient.toShortString()) .format() } + + else -> { + Log.w(TAG, "Something else happened in updatePlaceholder - we're not sure what.") + "" + } } val showPlaceholder = adapter.itemCount == 0 diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index 08aad8b6df..35c1307f3b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -633,7 +633,11 @@ open class Storage( // Notify the user val threadID = getOrCreateThreadIdFor(Address.fromSerialized(groupId)) threadDb.setDate(threadID, formationTimestamp) - insertOutgoingInfoMessage(context, groupId, SignalServiceGroup.Type.CREATION, title, members.map { it.serialize() }, admins.map { it.serialize() }, threadID, formationTimestamp) + + // ACL Note: Commenting out this line prevents the timestamp of room creation being added to a new closed group, + // which in turn allows us to show the `groupNoMessages` control message text. + //insertOutgoingInfoMessage(context, groupId, SignalServiceGroup.Type.CREATION, title, members.map { it.serialize() }, admins.map { it.serialize() }, threadID, formationTimestamp) + // Don't create config group here, it's from a config update // Start polling ClosedGroupPollerV2.shared.startPolling(group.accountId) diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSenderClosedGroupHandler.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSenderClosedGroupHandler.kt index 9c67a3b479..82ba565319 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSenderClosedGroupHandler.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSenderClosedGroupHandler.kt @@ -70,7 +70,10 @@ fun MessageSender.create( // Notify the user val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID)) - storage.insertOutgoingInfoMessage(context, groupID, SignalServiceGroup.Type.CREATION, name, members, admins, threadID, sentTime) + + // ACL Note: Commenting out this line prevents the timestamp of room creation being added to a new closed group, + // which in turn allows us to show the `groupNoMessages` control message text. + //storage.insertOutgoingInfoMessage(context, groupID, SignalServiceGroup.Type.CREATION, name, members, admins, threadID, sentTime) val ourPubKey = storage.getUserPublicKey() for (member in members) {