This commit is contained in:
2 files changed
+16
-3
No files matched your search
@@ -158,7 +158,13 @@ fun ChannelsScreen(
|
|||||||
|
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
viewModel.configurePlatform(platform.id, inputValues.toMap())
|
viewModel.configurePlatform(
|
||||||
|
platform.id,
|
||||||
|
MessagingPlatformUpdate(
|
||||||
|
enabled = platform.enabled,
|
||||||
|
env = inputValues.toMap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
showConfigureForm = false
|
showConfigureForm = false
|
||||||
},
|
},
|
||||||
modifier = Modifier.align(Alignment.End),
|
modifier = Modifier.align(Alignment.End),
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class ChannelsViewModel : ViewModel() {
|
|||||||
platformId: String,
|
platformId: String,
|
||||||
update: MessagingPlatformUpdate,
|
update: MessagingPlatformUpdate,
|
||||||
) {
|
) {
|
||||||
|
_uiState.update { it.copy(isLoading = true, errorMessage = null) }
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val result =
|
val result =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
@@ -61,12 +62,18 @@ class ChannelsViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
when (result) {
|
when (result) {
|
||||||
is NetworkResult.Success -> {
|
is NetworkResult.Success -> {
|
||||||
_uiState.update { it.copy(toastMessage = "$platformId configured successfully") }
|
_uiState.update { it.copy(isLoading = false, toastMessage = "$platformId configured successfully") }
|
||||||
loadPlatforms()
|
loadPlatforms()
|
||||||
}
|
}
|
||||||
|
|
||||||
is NetworkResult.Failure -> {
|
is NetworkResult.Failure -> {
|
||||||
_uiState.update { it.copy(toastMessage = "Failed to configure platform: ${result.error.message}") }
|
_uiState.update {
|
||||||
|
it.copy(
|
||||||
|
isLoading = false,
|
||||||
|
errorMessage = "Failed to configure platform: ${result.error.message}",
|
||||||
|
toastMessage = "Failed to configure platform: ${result.error.message}",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user