Fix log screen search input and always show toolbar actions
- Fix search TextField cursor issue by immediately updating searchQuery in uiState, keeping debounce only for log filtering - Always show toolbar buttons regardless of log list empty state
This commit is contained in:
@@ -525,13 +525,10 @@ class ComposeActivity : ComponentActivity(), ServiceConnection.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
// Show actions only for Log screen and when logs are not empty
|
||||
if (currentScreen == Screen.Log && logViewModel != null) {
|
||||
val logUiState by logViewModel.uiState.collectAsState()
|
||||
|
||||
// Only show toolbar actions if logs are not empty and not in selection mode
|
||||
if (logUiState.logs.isNotEmpty() && !logUiState.isSelectionMode) {
|
||||
// Pause/Resume button
|
||||
if (!logUiState.isSelectionMode) {
|
||||
IconButton(onClick = { logViewModel.togglePause() }) {
|
||||
Icon(
|
||||
imageVector =
|
||||
@@ -551,7 +548,6 @@ class ComposeActivity : ComponentActivity(), ServiceConnection.Callback {
|
||||
)
|
||||
}
|
||||
|
||||
// Search button
|
||||
IconButton(onClick = { logViewModel.toggleSearch() }) {
|
||||
Icon(
|
||||
imageVector =
|
||||
@@ -577,7 +573,6 @@ class ComposeActivity : ComponentActivity(), ServiceConnection.Callback {
|
||||
)
|
||||
}
|
||||
|
||||
// Options menu button
|
||||
IconButton(onClick = { logViewModel.toggleOptionsMenu() }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.MoreVert,
|
||||
@@ -585,7 +580,7 @@ class ComposeActivity : ComponentActivity(), ServiceConnection.Callback {
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
}
|
||||
} // End of logs.isNotEmpty() check
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(),
|
||||
|
||||
@@ -83,8 +83,7 @@ class LogViewModel : ViewModel(), CommandClient.Handler {
|
||||
_searchQueryInternal
|
||||
.debounce(300)
|
||||
.distinctUntilChanged()
|
||||
.collect { query ->
|
||||
_uiState.update { it.copy(searchQuery = query) }
|
||||
.collect { _ ->
|
||||
updateDisplayedLogs()
|
||||
}
|
||||
}
|
||||
@@ -201,6 +200,7 @@ class LogViewModel : ViewModel(), CommandClient.Handler {
|
||||
}
|
||||
|
||||
fun updateSearchQuery(query: String) {
|
||||
_uiState.update { it.copy(searchQuery = query) }
|
||||
_searchQueryInternal.value = query
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user