Skip to content
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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ private fun HomeScreen(
Spacer(modifier = Modifier.height(20.dp))

CloseMatching(
myProfileId = uiState.activeMyProfile.myProfileInfo.profileId,
myNickname = uiState.activeMyProfile.nickname,
matchedUser = uiState.matchedUser,
onClick = { matching ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.smashing.app.R.drawable.img_dummy_versus
import com.smashing.app.R.drawable.img_profile
import com.smashing.app.R.string.home_btn_go_to_matching_search
import com.smashing.app.R.string.home_no_matching
import com.smashing.app.R.drawable.img_profile
import com.smashing.app.core.designsystem.component.button.SmashingBaseButton
import com.smashing.app.core.designsystem.component.image.UrlImage
import com.smashing.app.core.designsystem.style.SmashingBtnColor
Expand All @@ -40,7 +40,6 @@ import com.smashing.app.data.model.matching.AcceptedMatching
@Composable
fun CloseMatching(
myNickname: String,
myProfileId: String,
onClick: (AcceptedMatching) -> Unit,
modifier: Modifier = Modifier,
matchedUser: AcceptedMatching? = null,
Expand Down Expand Up @@ -78,13 +77,11 @@ fun CloseMatching(
)

MatchedUserItem(
userId = myProfileId,
nickname = myNickname,
modifier = Modifier.align(Alignment.CenterStart)
)

MatchedUserItem(
userId = matchedUser.profileId,
nickname = matchedUser.nickname,
modifier = Modifier.align(Alignment.CenterEnd)
)
Expand Down Expand Up @@ -145,7 +142,6 @@ fun CloseMatching(

@Composable
private fun MatchedUserItem(
userId: String,
nickname: String,
modifier: Modifier = Modifier,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface RankingContract {
val totalRankingList: ImmutableList<UserRank> = persistentListOf(),
val topRankingList: ImmutableList<UserRank> = persistentListOf(),
val restRankingList: ImmutableList<UserRank> = persistentListOf(),
val userInfo: UserRank? = null,
val myRankInfo: UserRank? = null,
)
}

Expand All @@ -26,4 +26,4 @@ sealed interface RankingUiState{
data class Failure(
val msg: String,
) : RankingUiState
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.smashing.app.R.drawable.img_profile
import com.smashing.app.R.string.ranking_empty_title
import com.smashing.app.R.string.ranking_title
import com.smashing.app.R.string.ranking_tier_with_lp
import com.smashing.app.R.string.ranking_title
import com.smashing.app.core.designsystem.component.image.UrlImage
import com.smashing.app.core.designsystem.component.ranking.SmashingRankingItem
import com.smashing.app.core.designsystem.component.topbar.SmashingDefaultTopBar
Expand Down Expand Up @@ -123,7 +123,7 @@ private fun RankingScreen(

Ranker(
rankerList = uiState.topRankingList,
myUserId = uiState.userInfo?.userProfileId,
myProfileId = uiState.myRankInfo?.userProfileId,
navigateToProfile = navigateToProfile,
navigateToMyProfile = navigateToMyProfile,
)
Expand Down Expand Up @@ -161,7 +161,7 @@ private fun RankingScreen(
tier = user.tier,
lp = user.lp,
onClick = {
if (user.userProfileId != uiState.userInfo?.userProfileId) {
if (user.userProfileId != uiState.myRankInfo?.userProfileId) {
navigateToProfile(user.userProfileId)
} else {
navigateToMyProfile()
Expand Down Expand Up @@ -195,9 +195,9 @@ private fun RankingScreen(


}
if (uiState.userInfo != null) {
if (uiState.myRankInfo != null) {
MyRanking(
myRank = uiState.userInfo,
myRank = uiState.myRankInfo,
modifier = Modifier
.fillMaxWidth()
.align(Alignment.BottomCenter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class RankingViewModel @Inject constructor(
totalRankingList = userRankList.toImmutableList(),
topRankingList = userRankList.take(3).toImmutableList(),
restRankingList = userRankList.drop(3).toImmutableList(),
userInfo = rankingData.myRank?.let { user ->
myRankInfo = rankingData.myRank?.let { user ->
UserRank(
userProfileId = storedUserProfileId ?: "",
nickname = user.nickname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private const val RANKER_OTHER_WIDTH_RATIO = 0.33f
@Composable
fun Ranker(
rankerList: ImmutableList<UserRank>?,
myUserId: String?,
myProfileId: String?,
navigateToMyProfile: () -> Unit,
navigateToProfile: (String) -> Unit,
modifier: Modifier = Modifier,
Expand All @@ -77,9 +77,9 @@ fun Ranker(
val firstWidth = contentAreaWidth * RANKER_FIRST_WIDTH_RATIO + centerExtraWidth
val otherWidth = contentAreaWidth * RANKER_OTHER_WIDTH_RATIO

val onProfileClick: (String) -> Unit = { userId ->
if (userId != myUserId) {
navigateToProfile(userId)
val onProfileClick: (String) -> Unit = { userProfileId ->
if (userProfileId != myProfileId) {
navigateToProfile(userProfileId)
} else {
navigateToMyProfile()
}
Comment on lines +80 to 85

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

onProfileClick가 항상 내 프로필로 이동합니다.

람다 파라미터 userProfileId가 바깥의 userProfileId를 가려서, Line 81 비교가 항상 자기 자신과의 비교가 됩니다. 현재 상태로는 상위 랭커를 눌러도 navigateToMyProfile()만 호출됩니다.

수정 예시
-        val onProfileClick: (String) -> Unit = { userProfileId ->
-            if (userProfileId != userProfileId) {
-                navigateToProfile(userProfileId)
+        val onProfileClick: (String) -> Unit = { clickedUserProfileId ->
+            if (clickedUserProfileId != userProfileId) {
+                navigateToProfile(clickedUserProfileId)
             } else {
                 navigateToMyProfile()
             }
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/smashing/app/presentation/ranking/component/RankerItem.kt`
around lines 80 - 85, The lambda onProfileClick currently shadows the outer
userProfileId so the comparison always succeeds and navigateToMyProfile() is
always called; rename the lambda parameter (e.g., targetProfileId) or explicitly
reference the outer property to compare the clicked profile id with the current
user's id, then call navigateToProfile(targetProfileId) when they differ and
navigateToMyProfile() when they are equal; update the onProfileClick declaration
and its uses accordingly to eliminate the shadowing bug.

Expand Down Expand Up @@ -347,7 +347,7 @@ private fun RankerPreview_AllThree() {
color = colors.bgCanvas,
),
navigateToProfile = {},
myUserId = null,
myProfileId = null,
navigateToMyProfile = {},
)
}
Expand All @@ -373,7 +373,7 @@ private fun RankerPreview_FirstAndSecond() {
),
).toImmutableList(),
navigateToProfile = {},
myUserId = null,
myProfileId = null,
navigateToMyProfile = {},
)
}
Expand All @@ -384,7 +384,7 @@ private fun RankerPreview_Empty() {
Ranker(
rankerList = null,
navigateToProfile = {},
myUserId = null,
myProfileId = null,
navigateToMyProfile = {},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import androidx.lifecycle.viewModelScope
import androidx.navigation.toRoute
import com.smashing.app.data.model.moderation.ReportSubmitResult
import com.smashing.app.data.repository.api.ModerationRepository
import com.smashing.app.presentation.report.navigation.ReportPage
import com.smashing.app.data.type.ReportType
import com.smashing.app.presentation.report.navigation.ReportPage
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -24,7 +24,7 @@ class ReportViewModel @Inject constructor(
private val moderationRepository: ModerationRepository,
) : ViewModel() {

private val reportedUserId = savedStateHandle.toRoute<ReportPage>().reportedUserId
private val reportedUserProfileId = savedStateHandle.toRoute<ReportPage>().reportedUserProfileId

private val _uiState = MutableStateFlow(ReportContract.State())
val uiState = _uiState.asStateFlow()
Expand Down Expand Up @@ -52,7 +52,7 @@ class ReportViewModel @Inject constructor(
null
}
moderationRepository.postReportUser(
reportedUserProfileId = reportedUserId,
reportedUserProfileId = reportedUserProfileId,
reportTypeCode = type.toString(),
reasonDetail = reasonDetail,
).let { result ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import com.smashing.app.presentation.report.ReportRoute
import kotlinx.serialization.Serializable

fun NavController.navigateToReport(
reportedUserId: String,
reportedUserProfileId: String,
navOptions: NavOptions? = null,
) = navigate(ReportPage(reportedUserId), navOptions)
) = navigate(ReportPage(reportedUserProfileId), navOptions)

fun NavGraphBuilder.reportGraph(
innerPadding: PaddingValues,
Expand All @@ -30,5 +30,5 @@ fun NavGraphBuilder.reportGraph(

@Serializable
data class ReportPage(
val reportedUserId: String,
val reportedUserProfileId: String,
) : Route
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ fun SearchInputRoute(
items = uiState.suggestions,
searchState = viewModel.searchInputState,
onBackClick = navigateToSearchMain,
onSuggestionItemClick = { userId ->
navigateToUserProfile(userId)
},
onSuggestionItemClick = navigateToUserProfile,
modifier = modifier,
)
}
Expand Down
Loading