Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f866f04

Browse files
committed
Migrate Stream Chat SDK to 5.0.1
1 parent 47113d8 commit f866f04

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

‎app/src/main/kotlin/io/getstream/streamdraw/di/StreamModule.kt‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import dagger.Provides
2121
import dagger.hilt.InstallIn
2222
import dagger.hilt.components.SingletonComponent
2323
import io.getstream.chat.android.client.ChatClient
24-
import io.getstream.chat.android.offline.ChatDomain
2524
import javax.inject.Singleton
2625

2726
@Module
@@ -31,8 +30,4 @@ object StreamModule {
3130
@Provides
3231
@Singleton
3332
fun provideStreamChatClient() = ChatClient.instance()
34-
35-
@Provides
36-
@Singleton
37-
fun provideStreamChatDomain() = ChatDomain.instance()
3833
}

‎app/src/main/kotlin/io/getstream/streamdraw/initializer/StreamChatInitializer.kt‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import android.content.Context
2020
import androidx.startup.Initializer
2121
import io.getstream.chat.android.client.ChatClient
2222
import io.getstream.chat.android.client.logger.ChatLogLevel
23-
import io.getstream.chat.android.livedata.ChatDomain
23+
import io.getstream.chat.android.offline.model.message.attachments.UploadAttachmentsNetworkType
24+
import io.getstream.chat.android.offline.plugin.configuration.Config
25+
import io.getstream.chat.android.offline.plugin.factory.StreamOfflinePluginFactory
2426
import io.getstream.streamdraw.BuildConfig
2527
import io.getstream.streamdraw.R
2628
import timber.log.Timber
@@ -39,18 +41,18 @@ class StreamChatInitializer : Initializer<Unit> {
3941
* e.g, connect/disconnect user to the server, send/update/pin message, etc.
4042
*/
4143
val logLevel = if (BuildConfig.DEBUG) ChatLogLevel.ALL else ChatLogLevel.NOTHING
42-
val chatClient: ChatClient =
43-
ChatClient.Builder(context.getString(R.string.stream_api_key), context)
44-
.logLevel(logLevel)
45-
.build()
46-
47-
/**
48-
* initialize a global instance of the [ChatDomain].
49-
* The ChatDomain is the main entry point for all livedata & offline operations on chat.
50-
* e.g, querying available channel lists, querying users, etc.
51-
*/
52-
ChatDomain.Builder(chatClient, context)
53-
.offlineEnabled()
44+
val offlinePluginFactory = StreamOfflinePluginFactory(
45+
config = Config(
46+
backgroundSyncEnabled = true,
47+
userPresence = true,
48+
persistenceEnabled = true,
49+
uploadAttachmentsNetworkType = UploadAttachmentsNetworkType.NOT_ROAMING,
50+
),
51+
appContext = context,
52+
)
53+
ChatClient.Builder(context.getString(R.string.stream_api_key), context)
54+
.withPlugin(offlinePluginFactory)
55+
.logLevel(logLevel)
5456
.build()
5557
}
5658

‎app/src/main/kotlin/io/getstream/streamdraw/ui/screens/main/MainViewModel.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class MainViewModel @Inject constructor(
9090
return chatClient.createChannel(
9191
channelType = CHANNEL_MESSAGING,
9292
channelId = groupId,
93-
members = listOf(userId),
93+
memberIds = listOf(userId),
9494
extraData = mapOf(
9595
KEY_NAME to displayName.groupName,
9696
KEY_HOST_NAME to displayName,
@@ -123,7 +123,7 @@ class MainViewModel @Inject constructor(
123123
if (connection.isSuccess) {
124124
_gameConnectionState.emit(GameConnectionState.Loading)
125125
val channelClient = chatClient.channel(groupId.toChannelId())
126-
val result = channelClient.addMembers(userId).await()
126+
val result = channelClient.addMembers(listOf(userId)).await()
127127
if (result.isSuccess) {
128128
_gameConnectionState.emit(GameConnectionState.Success(result.data()))
129129
} else {

‎dependencies.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ext.versions = [
2525
hiltComposeNavigation: '1.0.0',
2626

2727
// stream chat SDK
28-
streamChatSDK : '4.30.1-beta',
28+
streamChatSDK : '5.0.1',
2929

3030
// sketchbook
3131
sketchbook : '1.0.3-20220310.123111-3',

0 commit comments

Comments
 (0)