Skip to content

Commit 6bb162e

Browse files
authored
Merge pull request #351 from skydoves/stream-chat/6.4.3
Migrate to Stream Chat SDK to 6.4.3
2 parents 3b0639a + 62e3ac4 commit 6bb162e

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

app/src/main/kotlin/com/skydoves/chatgpt/ChatGPTApp.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.skydoves.chatgpt
1818

1919
import android.app.Application
20-
import com.skydoves.snitcher.Snitcher
2120
import dagger.hilt.android.HiltAndroidApp
2221

2322
@HiltAndroidApp
@@ -28,6 +27,6 @@ class ChatGPTApp : Application() {
2827

2928
// install Snitcher to trace global exceptions and restore the app.
3029
// https://github.com/skydoves/snitcher
31-
Snitcher.install(this)
30+
// Snitcher.install(this)
3231
}
3332
}

feature-chat/src/main/kotlin/com/skydoves/chatgpt/feature/chat/messages/ChatGPTMessages.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ fun ChatGPTMessages(
254254
listViewModel,
255255
composerViewModel
256256
)
257-
}
257+
},
258+
reactionSorting = { _, _ -> 0 }
258259
)
259260
}
260261
}
@@ -327,7 +328,13 @@ private fun MessageDialogs(listViewModel: MessageListViewModel) {
327328
message = stringResource(
328329
id = io.getstream.chat.android.compose.R.string.stream_compose_flag_message_text
329330
),
330-
onPositiveAction = { listViewModel.flagMessage(flagAction.message) },
331+
onPositiveAction = {
332+
listViewModel.flagMessage(
333+
flagAction.message,
334+
customData = mapOf(),
335+
reason = null
336+
)
337+
},
331338
onDismiss = { listViewModel.dismissMessageAction(flagAction) }
332339
)
333340
}

feature-chat/src/main/kotlin/com/skydoves/chatgpt/feature/chat/messages/ChatGPTMessagesViewModel.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import com.skydoves.chatgpt.feature.chat.worker.ChatGPTMessageWorker.Companion.D
3535
import com.skydoves.chatgpt.feature.chat.worker.ChatGPTMessageWorker.Companion.DATA_MESSAGE_ID
3636
import com.skydoves.chatgpt.feature.chat.worker.ChatGPTMessageWorker.Companion.DATA_SUCCESS
3737
import com.skydoves.chatgpt.feature.chat.worker.ChatGPTMessageWorker.Companion.MESSAGE_EXTRA_CHAT_GPT
38-
import com.skydoves.viewmodel.lifecycle.viewModelLifecycleOwner
3938
import dagger.hilt.android.lifecycle.HiltViewModel
4039
import io.getstream.chat.android.client.ChatClient
4140
import io.getstream.chat.android.models.Message
@@ -47,6 +46,7 @@ import javax.inject.Inject
4746
import kotlinx.coroutines.flow.MutableStateFlow
4847
import kotlinx.coroutines.flow.SharingStarted
4948
import kotlinx.coroutines.flow.StateFlow
49+
import kotlinx.coroutines.flow.collectLatest
5050
import kotlinx.coroutines.flow.filter
5151
import kotlinx.coroutines.flow.map
5252
import kotlinx.coroutines.flow.stateIn
@@ -93,20 +93,20 @@ class ChatGPTMessagesViewModel @Inject constructor(
9393
val workRequest = buildGPTMessageWorkerRequest(text, lastGptMessage)
9494
workManager.enqueue(workRequest)
9595

96-
val workInfo = workManager.getWorkInfoByIdLiveData(workRequest.id)
97-
workInfo.observe(viewModelLifecycleOwner) {
98-
if (it.state == WorkInfo.State.SUCCEEDED) {
99-
val gptMessageText = it.outputData.getString(DATA_SUCCESS)
100-
val gptMessageId = it.outputData.getString(DATA_MESSAGE_ID)
101-
streamLog { "gpt message worker success: $gptMessageId $gptMessageText" }
102-
messageItemSet.value -= text
103-
} else if (it.state == WorkInfo.State.FAILED) {
104-
val error = it.outputData.getString(DATA_FAILURE) ?: ""
105-
streamLog { "gpt message worker failed: $error" }
106-
messageItemSet.value -= messageItemSet.value
107-
mutableError.value = error
96+
workManager.getWorkInfoByIdFlow(workRequest.id)
97+
.collectLatest {
98+
if (it.state == WorkInfo.State.SUCCEEDED) {
99+
val gptMessageText = it.outputData.getString(DATA_SUCCESS)
100+
val gptMessageId = it.outputData.getString(DATA_MESSAGE_ID)
101+
streamLog { "gpt message worker success: $gptMessageId $gptMessageText" }
102+
messageItemSet.value -= text
103+
} else if (it.state == WorkInfo.State.FAILED) {
104+
val error = it.outputData.getString(DATA_FAILURE) ?: ""
105+
streamLog { "gpt message worker failed: $error" }
106+
messageItemSet.value -= messageItemSet.value
107+
mutableError.value = error
108+
}
108109
}
109-
}
110110
}
111111
}
112112

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[versions]
2-
streamChatSDK = "6.3.1"
2+
streamChatSDK = "6.4.3"
33
streamLog = "1.1.4"
44
balloon = "1.6.5"
55
landscapist = "2.3.6"
6-
androidGradlePlugin = "8.5.1"
6+
androidGradlePlugin = "8.4.2"
77
androidxActivity = "1.9.0"
88
androidxAppCompat = "1.7.0"
99
androidxCompose = "1.6.8"

0 commit comments

Comments
 (0)