Skip to content

Commit a6682ac

Browse files
authored
Merge pull request #19 from GetStream/fix_enqueue
Fix sample app crash - not waiting for connect user
2 parents 305cbe7 + d2b77b7 commit a6682ac

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ android {
4747
}
4848

4949
dependencies {
50-
implementation "io.getstream:stream-chat-android-compose:6.0.2"
51-
implementation "io.getstream:stream-chat-android-offline:6.0.2"
50+
implementation "io.getstream:stream-chat-android-compose:6.0.8"
51+
implementation "io.getstream:stream-chat-android-offline:6.0.8"
5252

5353
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
5454
implementation("androidx.activity:activity-compose:1.7.2")

app/src/main/java/com/example/chattutorial/MainActivity.kt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.chattutorial
22

33
import android.os.Bundle
4+
import android.widget.Toast
45
import androidx.activity.ComponentActivity
56
import androidx.activity.compose.setContent
67
import androidx.compose.ui.res.stringResource
@@ -42,22 +43,27 @@ class MainActivity : ComponentActivity() {
4243
name = "Tutorial Droid",
4344
image = "https://bit.ly/2TIt8NR"
4445
)
46+
4547
client.connectUser(
4648
user = user,
4749
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidHV0b3JpYWwtZHJvaWQifQ.WwfBzU1GZr0brt_fXnqKdKhz3oj0rbDUm2DqJO_SS5U"
48-
).enqueue()
49-
50-
// 4 - Set up the Channels Screen UI
51-
setContent {
52-
ChatTheme {
53-
ChannelsScreen(
54-
title = stringResource(id = R.string.app_name),
55-
isShowingSearch = true,
56-
onItemClick = { channel ->
57-
startActivity(MessagesActivity4.getIntent(this, channel.cid))
58-
},
59-
onBackPressed = { finish() }
60-
)
50+
).enqueue {
51+
if (it.isSuccess) {
52+
// 4 - Set up the Channels Screen UI
53+
setContent {
54+
ChatTheme {
55+
ChannelsScreen(
56+
title = stringResource(id = R.string.app_name),
57+
isShowingSearch = true,
58+
onItemClick = { channel ->
59+
startActivity(MessagesActivity4.getIntent(this@MainActivity, channel.cid))
60+
},
61+
onBackPressed = { finish() }
62+
)
63+
}
64+
}
65+
} else {
66+
Toast.makeText(this, "something went wrong!", Toast.LENGTH_SHORT).show()
6167
}
6268
}
6369
}

0 commit comments

Comments
 (0)