From e92d5b9bc5fea772f4132867e00298657c69d5c4 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 19 Oct 2023 18:58:24 +0200 Subject: [PATCH] fix: channel groups are temporarily duplicated after editing --- .../com/github/libretube/ui/sheets/EditChannelGroupSheet.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/EditChannelGroupSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/EditChannelGroupSheet.kt index 4f93d224b..32324c70c 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/EditChannelGroupSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/EditChannelGroupSheet.kt @@ -72,7 +72,11 @@ class EditChannelGroupSheet : ExpandedBottomSheet() { } private fun saveGroup(group: SubscriptionGroup, oldGroupName: String) { - channelGroupsModel.groups.value = channelGroupsModel.groups.value?.plus(group) + // delete the old instance if the group already existed and add the updated/new one + channelGroupsModel.groups.value = channelGroupsModel.groups.value + ?.filter { it.name != oldGroupName } + ?.plus(group) + CoroutineScope(Dispatchers.IO).launch { runCatching { // delete the old one as it might have a different name