From d7abfcfe7f3ac54aace1845bb07a45a400d52f8a Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 21 Jun 2024 15:57:35 +0200 Subject: [PATCH] fix: hide add to group button when not subscribed --- .../github/libretube/ui/extensions/SetupSubscriptionButton.kt | 3 ++- .../java/com/github/libretube/ui/fragments/ChannelFragment.kt | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/extensions/SetupSubscriptionButton.kt b/app/src/main/java/com/github/libretube/ui/extensions/SetupSubscriptionButton.kt index 2e060a1d64..d3a1f3b827 100644 --- a/app/src/main/java/com/github/libretube/ui/extensions/SetupSubscriptionButton.kt +++ b/app/src/main/java/com/github/libretube/ui/extensions/SetupSubscriptionButton.kt @@ -26,9 +26,10 @@ fun TextView.setupSubscriptionButton( CoroutineScope(Dispatchers.IO).launch { subscribed = isSubscribed ?: SubscriptionHelper.isSubscribed(channelId) - subscribed?.let { subscribed -> onIsSubscribedChange(subscribed) } withContext(Dispatchers.Main) { + subscribed?.let { subscribed -> onIsSubscribedChange(subscribed) } + if (subscribed == true) { this@setupSubscriptionButton.text = context.getString(R.string.unsubscribe) } else { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt index e25937fcd9..847b7d6179 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt @@ -160,7 +160,9 @@ class ChannelFragment : DynamicLayoutManagerFragment() { channelId, channelName, binding.notificationBell - ) + ) { isSubscribed -> + _binding?.addToGroup?.isVisible = isSubscribed + } binding.channelShare.setOnClickListener { val bundle = bundleOf(