mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
More group renaming
This commit is contained in:
parent
e89cbdf029
commit
0518134c88
@ -259,7 +259,7 @@ class ConfigToDatabaseSync @Inject constructor(
|
||||
val toAddCommunities = userGroups.communityInfo.filter { it.community.fullUrl() !in existingCommunities.map { it.value.joinURL } }
|
||||
val existingJoinUrls = existingCommunities.values.map { it.joinURL }
|
||||
|
||||
val existingLegacyClosedGroups = storage.getAllGroups(includeInactive = true).filter { it.isLegacyClosedGroup }
|
||||
val existingLegacyClosedGroups = storage.getAllGroups(includeInactive = true).filter { it.isLegacyGroup }
|
||||
val lgcIds = userGroups.legacyGroupInfo.map { it.accountId }
|
||||
val toDeleteLegacyClosedGroups = existingLegacyClosedGroups.filter { group ->
|
||||
GroupUtil.doubleDecodeGroupId(group.encodedId) !in lgcIds
|
||||
|
@ -182,8 +182,8 @@ object ConversationMenuHelper {
|
||||
R.id.menu_block_delete -> { blockAndDelete(context, thread) }
|
||||
R.id.menu_copy_account_id -> { copyAccountID(context, thread) }
|
||||
R.id.menu_copy_open_group_url -> { copyOpenGroupUrl(context, thread) }
|
||||
R.id.menu_edit_group -> { editClosedGroup(context, thread) }
|
||||
R.id.menu_leave_group -> { return leaveClosedGroup(context, thread, threadID, factory, storage, groupManager) }
|
||||
R.id.menu_edit_group -> { editGroup(context, thread) }
|
||||
R.id.menu_leave_group -> { return leaveGroup(context, thread, threadID, factory, storage, groupManager) }
|
||||
R.id.menu_invite_to_open_group -> { inviteContacts(context, thread) }
|
||||
R.id.menu_unmute_notifications -> { unmute(context, thread) }
|
||||
R.id.menu_mute_notifications -> { mute(context, thread) }
|
||||
@ -316,7 +316,7 @@ object ConversationMenuHelper {
|
||||
listener.copyOpenGroupUrl(thread)
|
||||
}
|
||||
|
||||
private fun editClosedGroup(context: Context, thread: Recipient) {
|
||||
private fun editGroup(context: Context, thread: Recipient) {
|
||||
when {
|
||||
thread.isGroupV2Recipient -> {
|
||||
context.startActivity(EditGroupActivity.createIntent(context, thread.address.serialize()))
|
||||
@ -331,7 +331,7 @@ object ConversationMenuHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun leaveClosedGroup(
|
||||
fun leaveGroup(
|
||||
context: Context,
|
||||
thread: Recipient,
|
||||
threadID: Long,
|
||||
@ -346,7 +346,7 @@ object ConversationMenuHelper {
|
||||
val accountID = TextSecurePreferences.getLocalNumber(context)
|
||||
val isCurrentUserAdmin = admins.any { it.toString() == accountID }
|
||||
|
||||
confirmAndLeaveClosedGroup(
|
||||
confirmAndLeaveGroup(
|
||||
context = context,
|
||||
groupName = group.title,
|
||||
isAdmin = isCurrentUserAdmin,
|
||||
@ -372,7 +372,7 @@ object ConversationMenuHelper {
|
||||
|
||||
val channel = Channel<Unit>()
|
||||
|
||||
confirmAndLeaveClosedGroup(
|
||||
confirmAndLeaveGroup(
|
||||
context = context,
|
||||
groupName = name,
|
||||
isAdmin = group.hasAdminKey(),
|
||||
@ -394,7 +394,7 @@ object ConversationMenuHelper {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun confirmAndLeaveClosedGroup(
|
||||
private fun confirmAndLeaveGroup(
|
||||
context: Context,
|
||||
groupName: String,
|
||||
isAdmin: Boolean,
|
||||
|
@ -509,7 +509,7 @@ private fun MutableUserGroupsConfig.initFrom(storage: StorageProtocol) {
|
||||
|
||||
storage
|
||||
.getAllGroups(includeInactive = false)
|
||||
.asSequence().filter { it.isLegacyClosedGroup && it.isActive && it.members.size > 1 }
|
||||
.asSequence().filter { it.isLegacyGroup && it.isActive && it.members.size > 1 }
|
||||
.mapNotNull { group ->
|
||||
val groupAddress = Address.fromSerialized(group.encodedId)
|
||||
val groupPublicKey = GroupUtil.doubleDecodeGroupID(groupAddress.serialize()).toHexString()
|
||||
|
@ -34,7 +34,7 @@ object ClosedGroupManager {
|
||||
}
|
||||
|
||||
fun ConfigFactory.updateLegacyGroup(group: GroupRecord) {
|
||||
if (!group.isLegacyClosedGroup) return
|
||||
if (!group.isLegacyGroup) return
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
val threadId = storage.getThreadId(group.encodedId) ?: return
|
||||
val groupPublicKey = GroupUtil.doubleEncodeGroupID(group.getId())
|
||||
|
@ -583,8 +583,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
val threadID = thread.threadId
|
||||
val recipient = thread.recipient
|
||||
|
||||
if (recipient.isGroupV2Recipient || recipient.isLegacyGroupRecipient) {
|
||||
ConversationMenuHelper.leaveClosedGroup(
|
||||
if (recipient.isGroupRecipient) {
|
||||
ConversationMenuHelper.leaveGroup(
|
||||
context = this,
|
||||
thread = recipient,
|
||||
threadID = threadID,
|
||||
|
@ -89,7 +89,7 @@ private fun getHighlight(query: String?, toSearch: String): Spannable? {
|
||||
|
||||
fun ContentView.bindModel(query: String?, model: LegacyGroupConversation) {
|
||||
binding.searchResultProfilePicture.isVisible = true
|
||||
binding.searchResultSubtitle.isVisible = model.groupRecord.isLegacyClosedGroup
|
||||
binding.searchResultSubtitle.isVisible = model.groupRecord.isLegacyGroup
|
||||
binding.searchResultTimestamp.isVisible = false
|
||||
val threadRecipient = Recipient.from(binding.root.context, Address.fromSerialized(model.groupRecord.encodedId), false)
|
||||
binding.searchResultProfilePicture.update(threadRecipient)
|
||||
@ -99,7 +99,7 @@ fun ContentView.bindModel(query: String?, model: LegacyGroupConversation) {
|
||||
val groupRecipients = model.groupRecord.members.map { Recipient.from(binding.root.context, it, false) }
|
||||
|
||||
val membersString = groupRecipients.joinToString(transform = Recipient::getSearchName)
|
||||
if (model.groupRecord.isLegacyClosedGroup) {
|
||||
if (model.groupRecord.isLegacyGroup) {
|
||||
binding.searchResultSubtitle.text = getHighlight(query, membersString)
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class ConfigurationMessage(var closedGroups: List<ClosedGroup>, var openGroups:
|
||||
val profileKey = ProfileKeyUtil.getProfileKey(context)
|
||||
val groups = storage.getAllGroups(includeInactive = false)
|
||||
for (group in groups) {
|
||||
if (group.isLegacyClosedGroup && group.isActive) {
|
||||
if (group.isLegacyGroup && group.isActive) {
|
||||
if (!group.members.contains(Address.fromSerialized(storage.getUserPublicKey()!!))) continue
|
||||
val groupPublicKey = GroupUtil.doubleDecodeGroupID(group.encodedId).toHexString()
|
||||
val encryptionKeyPair = storage.getLatestClosedGroupEncryptionKeyPair(groupPublicKey) ?: continue
|
||||
@ -137,7 +137,7 @@ class ConfigurationMessage(var closedGroups: List<ClosedGroup>, var openGroups:
|
||||
)
|
||||
closedGroups.add(closedGroup)
|
||||
}
|
||||
if (group.isOpenGroup) {
|
||||
if (group.isCommunity) {
|
||||
val threadID = storage.getThreadId(group.encodedId) ?: continue
|
||||
val openGroup = storage.getOpenGroup(threadID)
|
||||
val shareUrl = openGroup?.joinURL ?: continue
|
||||
|
@ -21,11 +21,11 @@ class GroupRecord(
|
||||
}
|
||||
}
|
||||
|
||||
val isOpenGroup: Boolean
|
||||
val isCommunity: Boolean
|
||||
get() = Address.fromSerialized(encodedId).isCommunity
|
||||
val isLegacyClosedGroup: Boolean
|
||||
val isLegacyGroup: Boolean
|
||||
get() = Address.fromSerialized(encodedId).isLegacyGroup
|
||||
val isClosedGroupV2: Boolean
|
||||
val isGroupV2: Boolean
|
||||
get() = Address.fromSerialized(encodedId).isGroupV2
|
||||
|
||||
init {
|
||||
|
@ -480,6 +480,10 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return address.isLegacyGroup();
|
||||
}
|
||||
|
||||
public boolean isGroupRecipient() {
|
||||
return address.isGroup();
|
||||
}
|
||||
|
||||
public boolean isGroupV2Recipient() {
|
||||
return address.isGroupV2();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user