From 10df22bd069d14914dd4c07fe034ec20bc71252d Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 15 Jan 2025 22:44:32 +0100 Subject: [PATCH] Observe comment count outside of lifecycle aware block --- .../ui/fragments/CommentsMainFragment.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/CommentsMainFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/CommentsMainFragment.kt index ed6c8d3fa1..caf154f6ac 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/CommentsMainFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/CommentsMainFragment.kt @@ -116,18 +116,16 @@ class CommentsMainFragment : Fragment() { commentPagingAdapter.submitData(it) } } + } + } - launch { - viewModel.commentCountLiveData.observe(viewLifecycleOwner) { commentCount -> - if (commentCount == null) return@observe + viewModel.commentCountLiveData.observe(viewLifecycleOwner) { commentCount -> + if (commentCount == null) return@observe - commentsSheet?.updateFragmentInfo( - false, - getString(R.string.comments_count, commentCount.formatShort()) - ) - } - } - } + commentsSheet?.updateFragmentInfo( + false, + getString(R.string.comments_count, commentCount.formatShort()) + ) } }