Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Search retain the query and results #1579

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
Expand All @@ -33,7 +33,7 @@ fun SearchTextField(
) {
val keyboardController = LocalSoftwareKeyboardController.current

TextField(
OutlinedTextField(
value = value,
onValueChange = onValueChange,
leadingIcon = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import app.tivi.screens.SearchScreen
import app.tivi.screens.ShowDetailsScreen
import app.tivi.util.Logger
import app.tivi.util.onException
import com.slack.circuit.retained.rememberRetained
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.Navigator
import com.slack.circuit.runtime.presenter.Presenter
Expand Down Expand Up @@ -54,12 +55,13 @@ class SearchPresenter(
override fun present(): SearchUiState {
val scope = rememberCoroutineScope()

var query by remember { mutableStateOf("") }
var query by rememberRetained { mutableStateOf("") }
var results by rememberRetained { mutableStateOf(emptyList<TiviShow>()) }

val uiMessageManager = remember { UiMessageManager() }

val loading by searchShows.inProgress.collectAsState(false)
val message by uiMessageManager.message.collectAsState(null)
var results by remember { mutableStateOf(emptyList<TiviShow>()) }

LaunchedEffect(query) {
// delay for 300 milliseconds. This has the same effect as debounce
Expand Down
Loading