Skip to content
Merged
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 @@ -86,6 +86,22 @@ fun ExploreFilterSection(
onFilterReset = { tempFilterState.reset() },
onSave = {
isFilterBottomSheetVisible = false

val categoryFilters = filterItems.categories.filter { tempFilterState.categories[it.id] == true }.map { it.name }
val regionFilters = filterItems.regions.filter { tempFilterState.regions[it.id] == true }.map { it.name }
val ageGroupFilters = filterItems.ages.filter { tempFilterState.ages[it.id] == true }.map { it.name }
val isLocalReviewEnabled = filterItems.properties.firstOrNull()?.let { tempFilterState.properties[it.id] == true } ?: false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

firstOrNull()을 사용한 방식이 취약할 수 있습니다.

현재 코드는 properties의 첫 번째 항목이 로컬 리뷰라고 가정하고 있습니다. 만약 속성의 순서가 변경되거나 로컬 리뷰 앞에 다른 속성이 추가되면 조용히 오동작할 수 있습니다.

Line 110에서 FilterCategory.LOCAL_REVIEW enum을 사용하는 것을 보면, 위치가 아닌 타입/카테고리로 로컬 리뷰 속성을 식별하는 방식이 더 안전할 것 같습니다.

다음과 같이 개선하는 것을 고려해보세요:

val isLocalReviewEnabled = filterItems.properties
    .find { /* 로컬 리뷰를 식별하는 조건, 예: it.category == FilterCategory.LOCAL_REVIEW */ }
    ?.let { tempFilterState.properties[it.id] == true } 
    ?: false
🤖 Prompt for AI Agents
In
app/src/main/java/com/spoony/spoony/presentation/explore/component/ExploreFilterSection.kt
around line 93, using properties.firstOrNull() to assume the first property is
the local review is fragile; instead locate the property by its category/type:
replace the firstOrNull() call with a search (e.g., find { it.category ==
FilterCategory.LOCAL_REVIEW } or whatever field identifies local review), then
check tempFilterState.properties[it.id] == true and fall back to false if not
found; ensure the enum FilterCategory.LOCAL_REVIEW is referenced correctly and
adjust null-safety accordingly.


if (categoryFilters.isNotEmpty() || regionFilters.isNotEmpty() || ageGroupFilters.isNotEmpty() || isLocalReviewEnabled) {
tracker.commonEvents.filterApplied(
pageApplied = "explore",
localReviewFilter = isLocalReviewEnabled,
categoryFilters = categoryFilters,
regionFilters = regionFilters,
ageGroupFilters = ageGroupFilters
)
}

onAction(ExploreAction.ApplyFilter(tempFilterState.toPersistent()))
},
onToggleFilter = { id, type ->
Expand Down