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

♻️ erase comment count & toast message #387

Merged
merged 4 commits into from
Oct 8, 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 @@ -61,22 +61,12 @@ class CommentFragment : Fragment() {
}

private fun observeViewModels() {
observeCommentEmptyState()
observeComments()
observeQuitCommentEvent()
observeShowCommentMenuEvent()
observeCommentMenuEvents()
}

private fun observeCommentEmptyState() {
viewModel.isCommentEmpty.observe(viewLifecycleOwner) { event ->
val isCommentEmpty = event.getContentIfNotHandled() ?: return@observe
if (isCommentEmpty) {
showToast(getString(R.string.comment_empty_list))
}
}
}

private fun observeComments() {
viewModel.comments.observe(viewLifecycleOwner) { comments ->
adapter.submitList(comments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ class CommentViewModel

val commentContent: MutableLiveData<String> = MutableLiveData()

private val _isCommentEmpty: MutableLiveData<Event<Boolean>> = MutableLiveData()
val isCommentEmpty: LiveData<Event<Boolean>>
get() = _isCommentEmpty

private val _quitCommentEvent: MutableLiveData<Event<Boolean>> = MutableLiveData()
val quitCommentEvent: LiveData<Event<Boolean>>
get() = _quitCommentEvent
Expand Down Expand Up @@ -81,12 +77,7 @@ class CommentViewModel
private fun initializeComments() {
viewModelScope.launch {
val comments = fetchComments()
if (comments.isEmpty()) {
_isCommentEmpty.value = Event(true)
return@launch
}
_comments.value =
comments.filter { it.userId !in (blockedUserIds.value ?: emptyList()) }
_comments.value = comments.filter { it.userId !in (blockedUserIds.value ?: emptyList()) }
Copy link

Choose a reason for hiding this comment

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

!in 이렇게 표현할수 있다는걸 알았네요!

}
}

Expand Down Expand Up @@ -118,13 +109,7 @@ class CommentViewModel
_showCommentMenuEvent.value = Event(comment)
}

fun blockUser(comment: Comment) {
viewModelScope.launch {
userControlRepository.blockUser(comment.userId)
}
}

fun onReportComment(
private fun onReportComment(
comment: Comment,
reportReason: ReportReason,
) {
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/main/res/layout/fragment_comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
android:id="@+id/tv_count_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
bind:commentCount="@{vm.commentCount}"
android:text="@string/comments"
android:textSize="18sp"
android:textStyle="bold"
tools:text="Comments 12"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<string name="report_title_dialog">Choose reason of report</string>
<string name="recipe_report_success">Recipe Report Success</string>
<string name="alert_message_fill_form">Please fill this form</string>
<string name="comments">Comments</string>


</resources>
Loading