Skip to content

Commit

Permalink
Merge pull request #106 from GetStream/stream/6.0.5
Browse files Browse the repository at this point in the history
Migrate Stream chat sdk to 6.0.5
  • Loading branch information
skydoves authored Oct 24, 2023
2 parents 706fee1 + 70010e1 commit a08ccb2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import androidx.compose.runtime.Immutable
import com.skydoves.sealedx.core.Extensive
import com.skydoves.sealedx.core.annotations.ExtensiveModel
import com.skydoves.sealedx.core.annotations.ExtensiveSealed
import io.getstream.chat.android.client.models.Channel
import io.getstream.chat.android.models.Channel
import io.getstream.video.android.core.Call

/**
Expand Down
3 changes: 2 additions & 1 deletion features/chats/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ dependencies {
implementation(project(":core:network"))
implementation(project(":core:data"))

// Stream Chat Compose
// Stream Chat SDK
api(libs.stream.chat.offline)
api(libs.stream.chat.compose)

implementation(libs.androidx.lifecycle.runtimeCompose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import android.content.Context
import androidx.startup.Initializer
import io.getstream.chat.android.client.ChatClient
import io.getstream.chat.android.client.logger.ChatLogLevel
import io.getstream.chat.android.client.models.User
import io.getstream.chat.android.offline.model.message.attachments.UploadAttachmentsNetworkType
import io.getstream.chat.android.offline.plugin.configuration.Config
import io.getstream.chat.android.models.User
import io.getstream.chat.android.offline.plugin.factory.StreamOfflinePluginFactory
import io.getstream.chat.android.state.plugin.config.StatePluginConfig
import io.getstream.chat.android.state.plugin.factory.StreamStatePluginFactory
import io.getstream.log.streamLog
import io.getstream.whatsappclone.chats.BuildConfig

Expand All @@ -42,16 +42,17 @@ class StreamChatInitializer : Initializer<Unit> {
*/
val logLevel = if (BuildConfig.DEBUG) ChatLogLevel.ALL else ChatLogLevel.NOTHING
val offlinePluginFactory = StreamOfflinePluginFactory(
config = Config(
appContext = context
)
val statePluginFactory = StreamStatePluginFactory(
config = StatePluginConfig(
backgroundSyncEnabled = true,
userPresence = true,
persistenceEnabled = true,
uploadAttachmentsNetworkType = UploadAttachmentsNetworkType.NOT_ROAMING
userPresence = true
),
appContext = context
)
val chatClient = ChatClient.Builder(BuildConfig.STREAM_API_KEY, context)
.withPlugin(offlinePluginFactory)
.withPlugins(offlinePluginFactory, statePluginFactory)
.logLevel(logLevel)
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import io.getstream.chat.android.compose.ui.messages.MessagesScreen
import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory
import io.getstream.whatsappclone.chats.theme.WhatsAppChatTheme

@Composable
Expand All @@ -42,7 +44,11 @@ fun WhatsAppMessages(
)

MessagesScreen(
channelId = channelId,
viewModelFactory = MessagesViewModelFactory(
context = LocalContext.current,
channelId = channelId,
messageLimit = 30
),
showHeader = false,
onBackPressed = { whatsAppMessagesViewModel.handleEvents(WhatsAppMessageEvent.NavigateUp) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import io.getstream.chat.android.client.ChatClient
import io.getstream.chat.android.client.utils.onError
import io.getstream.chat.android.client.utils.onSuccess
import io.getstream.whatsappclone.navigation.AppComposeNavigator
import io.getstream.whatsappclone.navigation.WhatsAppScreens
import io.getstream.whatsappclone.uistate.WhatsAppMessageUiState
Expand Down Expand Up @@ -63,7 +61,7 @@ class WhatsAppMessagesViewModel @Inject constructor(
viewModelScope.launch {
val result = chatClient.channel(channelId).watch().await()
result.onSuccess {
messageMutableUiState.value = WhatsAppMessageUiState.Success(result.data())
messageMutableUiState.value = WhatsAppMessageUiState.Success(result.getOrThrow())
}.onError {
messageMutableUiState.value = WhatsAppMessageUiState.Error
}
Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
streamChatSDK = "5.17.10"
streamChatSDK = "6.0.5"
streamVideoSDK = "0.3.4"
streamLog = "1.1.4"
sealedx = "1.0.1"
Expand Down Expand Up @@ -45,6 +45,7 @@ turbine = "1.0.0"

[libraries]
stream-chat-client = { group = "io.getstream", name = "stream-chat-android-client", version.ref = "streamChatSDK" }
stream-chat-offline = { group = "io.getstream", name = "stream-chat-android-offline", version.ref = "streamChatSDK" }
stream-chat-compose = { group = "io.getstream", name = "stream-chat-android-compose", version.ref = "streamChatSDK" }
stream-video-core = { group = "io.getstream", name = "stream-video-android-core", version.ref = "streamVideoSDK" }
stream-video-compose = { group = "io.getstream", name = "stream-video-android-compose", version.ref = "streamVideoSDK" }
Expand Down

0 comments on commit a08ccb2

Please sign in to comment.