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