mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Merge pull request #5825 from Bnyro/master
fix: channel groups duplicated after updating name
This commit is contained in:
commit
cc9e596244
@ -64,9 +64,11 @@ class EditChannelGroupSheet : ExpandedBottomSheet() {
|
||||
|
||||
updateConfirmStatus()
|
||||
binding.confirm.setOnClickListener {
|
||||
channelGroupsModel.groupToEdit?.name = binding.groupName.text.toString()
|
||||
if (channelGroupsModel.groupToEdit?.name.isNullOrBlank()) return@setOnClickListener
|
||||
saveGroup(channelGroupsModel.groupToEdit!!, oldGroupName)
|
||||
val updatedGroup = channelGroupsModel.groupToEdit?.copy(
|
||||
name = binding.groupName.text.toString().ifEmpty { return@setOnClickListener }
|
||||
) ?: return@setOnClickListener
|
||||
saveGroup(updatedGroup, oldGroupName)
|
||||
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@ -78,10 +80,9 @@ class EditChannelGroupSheet : ExpandedBottomSheet() {
|
||||
?.plus(group)
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
runCatching {
|
||||
// delete the old one as it might have a different name
|
||||
// delete the old version of the group first before updating it, as the name is the
|
||||
// primary key
|
||||
DatabaseHolder.Database.subscriptionGroupsDao().deleteGroup(oldGroupName)
|
||||
}
|
||||
DatabaseHolder.Database.subscriptionGroupsDao().createGroup(group)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user