Skip to content

Fix get sample usage #246

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

Merged
merged 1 commit into from
Oct 17, 2024
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 @@ -117,18 +117,4 @@ object DefaultSampleInfoRepository : SampleInfoRepository {
override fun getSamplesInCategory(sampleCategory: SampleCategory): List<Sample> {
return sampleList.filter { it.metadata.sampleCategory == sampleCategory }
}

/**
* Get a list of samples for the given category string.
*/
override fun getSamplesInCategory(sampleCategoryString: String): List<Sample> {
return sampleList.filter { it.metadata.sampleCategory.text == sampleCategoryString }
}

/**
* Get a list of all samples in the app.
*/
override fun getAllSamples(): List<Sample> {
return sampleList
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,5 @@ interface SampleInfoRepository {

fun getSamplesInCategory(sampleCategory: SampleCategory): List<Sample>

fun getSamplesInCategory(sampleCategoryString: String): List<Sample>

fun getSampleByName(sampleName: String): Sample

fun getAllSamples(): List<Sample>
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -139,8 +138,6 @@ fun SearchSuggestionsList(
onRelevantAPISelected: (String) -> Unit

) {
val samplesFromRepository by remember { mutableStateOf(DefaultSampleInfoRepository.getAllSamples()) }

Column(
modifier = Modifier
.fillMaxSize(),
Expand Down Expand Up @@ -169,8 +166,7 @@ fun SearchSuggestionsList(
key = { suggestion -> suggestion }
) { suggestion ->
if (suggestion.second) { // Sample Suggestion
val sample = samplesFromRepository.find { it.name == suggestion.first }
?: return@items
val sample = DefaultSampleInfoRepository.getSampleByName(suggestion.first)
Row(
modifier = Modifier
.animateItem()
Expand Down