File tree Expand file tree Collapse file tree
app/src/main/java/com/nextcloud/client/assistant Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,6 +330,7 @@ private fun InputBar(
330330) {
331331 val scope = rememberCoroutineScope()
332332 val text by viewModel.inputBarText.collectAsState()
333+ val chatUIState by chatViewModel.uiState.collectAsState()
333334
334335 Surface (
335336 tonalElevation = 3 .dp,
@@ -387,7 +388,8 @@ private fun InputBar(
387388 delay(CHAT_INPUT_DELAY )
388389 viewModel.updateInputBarText(" " )
389390 }
390- }
391+ },
392+ enabled = chatUIState.canSend()
391393 ) {
392394 Icon (
393395 painter = painterResource(id = R .drawable.ic_send),
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.height
2929import androidx.compose.foundation.layout.padding
3030import androidx.compose.foundation.layout.size
3131import androidx.compose.foundation.lazy.LazyColumn
32+ import androidx.compose.foundation.lazy.LazyListState
3233import androidx.compose.foundation.lazy.items
3334import androidx.compose.foundation.lazy.rememberLazyListState
3435import androidx.compose.foundation.shape.CircleShape
@@ -138,7 +139,7 @@ private fun ChatMessageList(
138139 messages : List <ChatMessage >,
139140 showTypingIndicator : Boolean ,
140141 modifier : Modifier = Modifier ,
141- listState : androidx.compose.foundation.lazy. LazyListState ,
142+ listState : LazyListState ,
142143 bottomSlot : (@Composable () -> Unit )? = null
143144) {
144145 LazyColumn (
Original file line number Diff line number Diff line change @@ -17,13 +17,15 @@ sealed class ChatUIState {
1717 data class Thinking (val messages : List <ChatMessage >) : ChatUIState()
1818 data class RetryAvailable (val messages : List <ChatMessage >) : ChatUIState()
1919 data class Error (val messages : List <ChatMessage >, val errorType : ChatErrorType ) : ChatUIState()
20- }
2120
22- fun ChatUIState.messages (): List <ChatMessage > = when (this ) {
23- is ChatUIState .Content -> messages
24- is ChatUIState .Sending -> messages
25- is ChatUIState .Thinking -> messages
26- is ChatUIState .RetryAvailable -> messages
27- is ChatUIState .Error -> messages
28- is ChatUIState .Loading , is ChatUIState .Empty -> emptyList()
21+ fun messages (): List <ChatMessage > = when (this ) {
22+ is Content -> messages
23+ is Sending -> messages
24+ is Thinking -> messages
25+ is RetryAvailable -> messages
26+ is Error -> messages
27+ is Loading , is Empty -> emptyList()
28+ }
29+
30+ fun canSend (): Boolean = (this == Empty || this is Content )
2931}
You can’t perform that action at this time.
0 commit comments