-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feature/#106] : Ban 기능 구현 + etc #112
Conversation
…ment list api version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domain분리 좋습니다1!
고생 많으셨어요 코리 달게 없네유
init { | ||
fetchIsAdmin() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
viewmodel에서 init블록을 사용하면 좋지 않다는 의견이 있어 달아 봅니다!
ViewModel 생성과 강하게 커플링됨
데이터를 가져오는 타이밍이 ViewModel 생성시에 있기 때문에, 새로고침 등 사용자 상호작용이나 기타 이벤트에 따라 데이터 로딩시점을 제어하기 어렵게 만든다.
-> 근데 여긴 작은 데이터라 굳이 상관 없어 보이긴해요
https://www.youtube.com/watch?v=mNKQ9dc1knI
https://proandroiddev.com/mastering-android-viewmodels-essential-dos-and-donts-part-1-%EF%B8%8F-bdf05287bca9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 좋은 글 공유 감사합니다 👍
private fun fetchIsAdmin() = viewModelScope.launch { | ||
userInfoRepository.getIsAdmin() | ||
.collectLatest { isAdmin = it } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그리고 만약 추후에 view단에서 sateFlow로 필요 하다면
val isPermissionState: StateFlow<Boolean> = userInfoRepository.getIsPushAlarmAllowed()
.catch {
_sideEffect.emit(ProfileSideEffect.ShowSnackBar(it))
}.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = false,
)
이런식으로 stateIn을 통해 cold stream인 flow를 hot stream으로 직접 변경하는 방법도 있습니다!
fun fetchUserType(): ProfileUserType = when (isAdmin) { | ||
true -> ProfileUserType.ADMIN | ||
false -> ProfileUserType.MEMBER | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분의 경우 onEach를 사용해서 이렇게 쓸 수 도 있을거 ㅅ같은데 해보진 않았어요 ㅎㅎ
val isAdminState: StateFlow<Boolean> = userInfoRepository.getIsPushAlarmAllowed()
.catch {
_sideEffect.emit(ProfileSideEffect.ShowSnackBar(it))
}.onEach {
fetchUserType(it)
}
.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = false,
)
view단에서 따로 수집할 필요가 없으면 지금 방식이 더 효율적일것 같긴 합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위 유투브에 나온대로 init을 안쓰고 onStart()를 쓴다면
val isAdminState: StateFlow<Boolean> = userInfoRepository.getIsPushAlarmAllowed()
.catch {
_sideEffect.emit(ProfileSideEffect.ShowSnackBar(it))
}.onStart {
fetchUserType()
}
.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = false,
)
fun fetchUserType(): ProfileUserType = when (isPermissionState.value) {
true -> ProfileUserType.ADMIN
false -> ProfileUserType.MEMBER
}
이런느낌이 아닐까 싶네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admin 값은 고정된 값이라 계속 수집할 필요는 없어보이고, 푸시 알림 여부 확인 로직 쪽에 반영해볼게요!
최고👍
✅ 𝗖𝗵𝗲𝗰𝗸-𝗟𝗶𝘀𝘁
📌 𝗜𝘀𝘀𝘂𝗲𝘀
📎𝗪𝗼𝗿𝗸 𝗗𝗲𝘀𝗰𝗿𝗶𝗽𝘁𝗶𝗼𝗻
Ban 기능 구현했습니다. (home feed, home detail feed, profile comment, profile feed)
로딩 뷰 빈도 조정했습니다.
레벨 태그 이미지 변경했습니다.
📷 𝗦𝗰𝗿𝗲𝗲𝗻𝘀𝗵𝗼𝘁
밴(블라인드)
default.mp4
로딩뷰 조정
default.mp4
💬 𝗧𝗼 𝗥𝗲𝘃𝗶𝗲𝘄𝗲𝗿𝘀
참고용 노션 링크