mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
fix: open group comparison issues potentially, have to update some more outgoing message open group flags for visibility of details etc
This commit is contained in:
parent
1c7841333a
commit
dec179f4e7
@ -501,7 +501,9 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
val communities = userGroups.allCommunityInfo()
|
||||
val lgc = userGroups.allLegacyGroupInfo()
|
||||
val allOpenGroups = getAllOpenGroups()
|
||||
val toDeleteCommunities = allOpenGroups.filter { it.value.joinURL !in communities.map { it.community.fullUrl() } }
|
||||
val toDeleteCommunities = allOpenGroups.filter {
|
||||
Conversation.Community(BaseCommunityInfo(it.value.server, it.value.room, it.value.publicKey), 0, false).baseCommunityInfo.fullUrl() !in communities.map { it.community.fullUrl() }
|
||||
}
|
||||
|
||||
val existingCommunities: Map<Long, OpenGroup> = allOpenGroups.filterKeys { it !in toDeleteCommunities.keys }
|
||||
val toAddCommunities = communities.filter { it.community.fullUrl() !in existingCommunities.map { it.value.joinURL } }
|
||||
@ -521,7 +523,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
toDeleteClosedGroups.forEach { deleteGroup ->
|
||||
val threadId = getThreadId(deleteGroup.encodedId)
|
||||
if (threadId != null) {
|
||||
Log.d("Loki-DBG", "Deleting group for thread $threadId")
|
||||
ClosedGroupManager.silentlyRemoveGroup(context,threadId,GroupUtil.doubleDecodeGroupId(deleteGroup.encodedId), deleteGroup.encodedId, localUserPublicKey, delete = true)
|
||||
}
|
||||
}
|
||||
@ -529,7 +530,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
toAddCommunities.forEach { toAddCommunity ->
|
||||
val joinUrl = toAddCommunity.community.fullUrl()
|
||||
if (!hasBackgroundGroupAddJob(joinUrl)) {
|
||||
Log.d("Loki-DBG", "Doesn't contain background job for open group, adding from config update")
|
||||
JobQueue.shared.add(BackgroundGroupAddJob(joinUrl))
|
||||
}
|
||||
}
|
||||
@ -550,7 +550,6 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
val existingGroup = existingClosedGroups.firstOrNull { GroupUtil.doubleDecodeGroupId(it.encodedId) == group.sessionId }
|
||||
val existingThread = existingGroup?.let { getThreadId(existingGroup.encodedId) }
|
||||
if (existingGroup != null) {
|
||||
Log.d("Loki-DBG", "Existing closed group, don't add")
|
||||
if (group.priority == PRIORITY_HIDDEN && existingThread != null) {
|
||||
threadDb.deleteConversation(existingThread)
|
||||
// TODO: stop polling here also
|
||||
|
@ -9,7 +9,6 @@ import org.session.libsession.messaging.open_groups.OpenGroup
|
||||
import org.session.libsession.messaging.open_groups.OpenGroupApi
|
||||
import org.session.libsession.messaging.sending_receiving.pollers.OpenGroupPoller
|
||||
import org.session.libsignal.utilities.Log
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||
import java.util.concurrent.Executors
|
||||
@ -106,6 +105,7 @@ object OpenGroupManager {
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun delete(server: String, room: String, context: Context) {
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
val configFactory = MessagingModuleConfiguration.shared.configFactory
|
||||
@ -133,12 +133,10 @@ object OpenGroupManager {
|
||||
storage.removeLastOutboxMessageId(server)
|
||||
val lokiThreadDB = DatabaseComponent.get(context).lokiThreadDatabase()
|
||||
lokiThreadDB.removeOpenGroupChat(threadID)
|
||||
ThreadUtils.queue {
|
||||
storage.deleteConversation(threadID) // Must be invoked on a background thread
|
||||
GroupManager.deleteGroup(groupID, context) // Must be invoked on a background thread
|
||||
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context)
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun addOpenGroup(urlAsString: String, context: Context): OpenGroupApi.RoomInfo? {
|
||||
|
@ -650,7 +650,9 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
// Delete the conversation
|
||||
val v2OpenGroup = DatabaseComponent.get(this@HomeActivity).lokiThreadDatabase().getOpenGroupChat(threadID)
|
||||
if (v2OpenGroup != null) {
|
||||
withContext(Dispatchers.IO) {
|
||||
OpenGroupManager.delete(v2OpenGroup.server, v2OpenGroup.room, this@HomeActivity)
|
||||
}
|
||||
} else {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
storage.deleteConversation(threadID)
|
||||
|
@ -60,7 +60,7 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() {
|
||||
profilePictureView.root.update(recipient)
|
||||
nameTextViewContainer.visibility = View.VISIBLE
|
||||
nameTextViewContainer.setOnClickListener {
|
||||
if (recipient.isOpenGroupInboxRecipient) return@setOnClickListener
|
||||
if (recipient.isOpenGroupInboxRecipient || recipient.isOpenGroupOutboxRecipient) return@setOnClickListener
|
||||
nameTextViewContainer.visibility = View.INVISIBLE
|
||||
nameEditTextContainer.visibility = View.VISIBLE
|
||||
nicknameEditText.text = null
|
||||
@ -88,8 +88,12 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() {
|
||||
nameTextView.text = recipient.name ?: publicKey // Uses the Contact API internally
|
||||
|
||||
nameEditIcon.isVisible = threadRecipient.isContactRecipient
|
||||
&& !threadRecipient.isOpenGroupInboxRecipient
|
||||
&& !threadRecipient.isOpenGroupOutboxRecipient
|
||||
|
||||
publicKeyTextView.isVisible = !threadRecipient.isOpenGroupRecipient && !threadRecipient.isOpenGroupInboxRecipient
|
||||
publicKeyTextView.isVisible = !threadRecipient.isOpenGroupRecipient
|
||||
&& !threadRecipient.isOpenGroupInboxRecipient
|
||||
&& !threadRecipient.isOpenGroupOutboxRecipient
|
||||
messageButton.isVisible = !threadRecipient.isOpenGroupRecipient || IdPrefix.fromValue(publicKey) == IdPrefix.BLINDED
|
||||
publicKeyTextView.text = publicKey
|
||||
publicKeyTextView.setOnLongClickListener {
|
||||
|
@ -5,6 +5,7 @@ import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.util.Pair
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import org.session.libsignal.utilities.IdPrefix
|
||||
import org.session.libsignal.utilities.Util
|
||||
import org.session.libsignal.utilities.guava.Optional
|
||||
import java.util.Collections
|
||||
@ -26,6 +27,8 @@ class Address private constructor(address: String) : Parcelable, Comparable<Addr
|
||||
get() = GroupUtil.isOpenGroup(address)
|
||||
val isOpenGroupInbox: Boolean
|
||||
get() = GroupUtil.isOpenGroupInbox(address)
|
||||
val isOpenGroupOutbox: Boolean
|
||||
get() = address.startsWith(IdPrefix.BLINDED.value)
|
||||
val isContact: Boolean
|
||||
get() = !(isGroup || isOpenGroupInbox)
|
||||
|
||||
|
@ -442,6 +442,10 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return address.isOpenGroup();
|
||||
}
|
||||
|
||||
public boolean isOpenGroupOutboxRecipient() {
|
||||
return address.isOpenGroupOutbox();
|
||||
}
|
||||
|
||||
public boolean isOpenGroupInboxRecipient() {
|
||||
return address.isOpenGroupInbox();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user