mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
join open group code executed in a coroutine so it's not blocking the UI
This commit is contained in:
parent
b562aa5738
commit
8dd606cbb3
@ -8,6 +8,9 @@ import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.utilities.GroupUtil
|
||||
import org.session.libsession.utilities.OpenGroupUrlParser
|
||||
@ -69,15 +72,27 @@ class OpenGroupInvitationView : FrameLayout {
|
||||
|
||||
builder.setMessage(message)
|
||||
builder.setPositiveButton(R.string.yes) { dialog, which ->
|
||||
try {
|
||||
val group = OpenGroupUtilities.addGroup(context, openGroup.server, openGroup.room, openGroup.serverPublicKey)
|
||||
val threadID = GroupManager.getOpenGroupThreadID(group.id, context)
|
||||
val groupID = GroupUtil.getEncodedOpenGroupID(group.id.toByteArray())
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
dialog.dismiss()
|
||||
val group = OpenGroupUtilities.addGroup(
|
||||
context,
|
||||
openGroup.server,
|
||||
openGroup.room,
|
||||
openGroup.serverPublicKey
|
||||
)
|
||||
val threadID = GroupManager.getOpenGroupThreadID(group.id, context)
|
||||
val groupID = GroupUtil.getEncodedOpenGroupID(group.id.toByteArray())
|
||||
|
||||
MultiDeviceProtocol.forceSyncConfigurationNowIfNeeded(context)
|
||||
} catch (e: Exception) {
|
||||
Log.e("JoinPublicChatActivity", "Failed to join open group.", e)
|
||||
Toast.makeText(context, R.string.activity_join_public_chat_error, Toast.LENGTH_SHORT).show()
|
||||
MultiDeviceProtocol.forceSyncConfigurationNowIfNeeded(context)
|
||||
} catch (e: Exception) {
|
||||
Log.e("JoinPublicChatActivity", "Failed to join open group.", e)
|
||||
Toast.makeText(
|
||||
context,
|
||||
R.string.activity_join_public_chat_error,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/open_group_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:clickable="false"
|
||||
android:visibility="gone"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_margin="4dp"
|
||||
android:contentDescription="@string/open_group_invitation_view__join_accessibility_description"
|
||||
android:src="@drawable/ic_globe" />
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user