Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ configurations.configureEach {
exclude(module = "commons-logging")
}

val canonicalVersionCode = 429
val canonicalVersionName = "1.29.0"
val canonicalVersionCode = 430
val canonicalVersionName = "1.29.1"

val postFixSize = 10
val abiPostFix = mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,10 @@ class ReceivedMessageHandler @Inject constructor(
runThreadUpdate = runThreadUpdate
) ?: return null

// If we have previously "hidden" the sender, we should flip the flag back to visible
if (senderAddress is Address.Standard && senderAddress.address != userPublicKey) {
// If we have previously "hidden" the sender, we should flip the flag back to visible,
// and this should only be done only for 1:1 messages
if (senderAddress is Address.Standard && senderAddress.address != userPublicKey
&& context.threadAddress is Address.Standard) {
val existingContact =
configFactory.withUserConfigs { it.contacts.get(senderAddress.accountId.hexString) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ sealed interface Address : Parcelable, Comparable<Address> {
/**
* A marker interface for addresses that represent a group-like entity.
*/
sealed interface GroupLike : Address
sealed interface GroupLike : Conversable

sealed interface WithAccountId {
val accountId: AccountId
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ class ConversationViewModel @AssistedInject constructor(
it.currentUserRole in EnumSet.of(GroupMemberRole.ADMIN, GroupMemberRole.HIDDEN_ADMIN)
}

val canModerate: StateFlow<Boolean> = recipientFlow.mapStateFlow(viewModelScope) {
it.currentUserRole.canModerate
}

private val _searchOpened = MutableStateFlow(false)

val appBarData: StateFlow<ConversationAppBarData> = combine(
Expand Down Expand Up @@ -750,7 +754,7 @@ class ConversationViewModel @AssistedInject constructor(
}

// If the user is an admin or is interacting with their own message And are allowed to delete for everyone
(isAdmin.value || allSentByCurrentUser) && canDeleteForEveryone -> {
(canModerate.value || allSentByCurrentUser) && canDeleteForEveryone -> {
_dialogsState.update {
it.copy(
deleteEveryone = DeleteForEveryoneDialogData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ public void postKey(SQLiteConnection connection) {
);

this.jsonProvider = jsonProvider;

Log.d(TAG, "SQLCipherOpenHelper created with database secret: " + databaseSecret.asString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class HomeActivity : ScreenLockActionBarActivity(),
is GlobalSearchAdapter.Model.GroupConversation -> ConversationActivityV2
.createIntent(
this,
address = Address.fromSerialized(model.groupId) as Address.Conversable
address = model.address
)

else -> {
Expand Down Expand Up @@ -466,7 +466,7 @@ class HomeActivity : ScreenLockActionBarActivity(),
.map {
GlobalSearchAdapter.Model.Contact(
contact = it.value,
isSelf = it.value.address.address == publicKey,
isSelf = it.value.isSelf,
showProBadge = it.value.proStatus.shouldShowProBadge()
)
}
Expand All @@ -479,8 +479,9 @@ class HomeActivity : ScreenLockActionBarActivity(),
isSelf = it.isSelf,
showProBadge = it.proStatus.shouldShowProBadge()
) } +
threads.map {
GlobalSearchAdapter.Model.GroupConversation(it, showProBadge = recipientRepository.getRecipientSync(it.encodedId.toAddress()).proStatus.shouldShowProBadge())
threads.mapNotNull {
if(it.address is Address.GroupLike) GlobalSearchAdapter.Model.GroupConversation(it)
else null
}

private val GlobalSearchResult.messageResults: List<GlobalSearchAdapter.Model> get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import org.session.libsession.messaging.MessagingModuleConfiguration
import org.session.libsession.utilities.Address
import org.session.libsession.utilities.GroupRecord
import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.recipients.RecipientData
import org.session.libsession.utilities.recipients.displayName
import org.session.libsession.utilities.recipients.shouldShowProBadge
import org.session.libsignal.utilities.AccountId
import org.session.libsignal.utilities.Log
import org.thoughtcrime.securesms.search.model.MessageResult
import org.thoughtcrime.securesms.ui.GetString
import org.thoughtcrime.securesms.util.DateUtils
Expand Down Expand Up @@ -147,6 +150,8 @@ class GlobalSearchAdapter(
onContactLongPressed(model)
true
}
} else {
binding.root.setOnLongClickListener(null)
}
}
}
Expand All @@ -167,26 +172,39 @@ class GlobalSearchAdapter(
this(contact.address as Address.Conversable, contact.displayName(false), isSelf, showProBadge)
}
data class GroupConversation(
val isLegacy: Boolean,
val groupId: String,
val address: Address.GroupLike,
val title: String,
val legacyMembersString: String?,
val showProBadge: Boolean
) : Model {
constructor(groupRecord: GroupRecord, showProBadge: Boolean):
constructor(recipient: Recipient):
this(
isLegacy = groupRecord.isLegacyGroup,
groupId = groupRecord.encodedId,
title = groupRecord.title,
legacyMembersString = if (groupRecord.isLegacyGroup) {
val recipients = groupRecord.members.map {
MessagingModuleConfiguration.shared.recipientRepository.getRecipientSync(it)
address = recipient.address as Address.GroupLike,
title = recipient.displayName(),
legacyMembersString = when (recipient.address) {
is Address.LegacyGroup -> {
val data = (recipient.data as? RecipientData.LegacyGroup)
if(data == null) null
else {
if(data.secondMember != null) "${data.firstMember.displayName()}, ${data.secondMember.displayName()}".plus(
if(data.members.size > 2) ", ..." else ""
)
else data.firstMember.displayName().plus(
if(data.members.size > 1) ", ..." else ""
)
}
}

is Address.Group -> {
val data = (recipient.data as? RecipientData.Group)
data?.partial?.members?.joinToString(", ") { it.name }
}

else -> {
null
}
recipients.joinToString(transform = { it.searchName })
} else {
null
},
showProBadge = showProBadge
showProBadge = recipient.proStatus.shouldShowProBadge()
)
}
data class Message(val messageResult: MessageResult, val unread: Int, val isSelf: Boolean, val showProBadge: Boolean) : Model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.recyclerview.widget.DiffUtil
import network.loki.messenger.R
import org.session.libsession.messaging.MessagingModuleConfiguration
import org.session.libsession.utilities.Address
import org.session.libsession.utilities.isLegacyGroup
import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.recipients.displayName
import org.session.libsession.utilities.truncateIdForDisplay
Expand Down Expand Up @@ -111,10 +112,9 @@ private fun ComposeView.setupTitleWithBadge(title: String, showProBadge: Boolean

fun ContentView.bindModel(query: String?, model: GroupConversation) {
binding.searchResultProfilePicture.isVisible = true
binding.searchResultSubtitle.isVisible = model.isLegacy
binding.searchResultTimestamp.isVisible = false
val threadRecipient = MessagingModuleConfiguration.shared.recipientRepository.getRecipientSync(
Address.fromSerialized(model.groupId)
model.address
)

binding.searchResultProfilePicture.setThemedContent {
Expand All @@ -130,7 +130,10 @@ fun ContentView.bindModel(query: String?, model: GroupConversation) {
)

if (model.legacyMembersString != null) {
binding.searchResultSubtitle.isVisible = true
binding.searchResultSubtitle.text = getHighlight(query, model.legacyMembersString)
} else {
binding.searchResultSubtitle.isVisible = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.thoughtcrime.securesms.search.model.SearchResult
data class GlobalSearchResult(
val query: String,
val contacts: List<Recipient> = emptyList(),
val threads: List<GroupRecord> = emptyList(),
val threads: List<Recipient> = emptyList(),
val messages: List<MessageResult> = emptyList(),
val showNoteToSelf: Boolean = false
) {
Expand Down
Loading