diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index d4a6711bc..300a507ea 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -189,7 +189,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { rootView?.apply { tocRule.name = tv_rule_name.text.toString() tocRule.rule = tv_rule_regex.text.toString() - viewModel.saveRule(tocRule, rule) + viewModel.saveRule(tocRule) } } cancelButton() diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt index 4a63120c8..9ed5ea3d3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt @@ -11,14 +11,11 @@ import io.legado.app.utils.fromJsonArray class TocRegexViewModel(application: Application) : BaseViewModel(application) { - fun saveRule(rule: TxtTocRule, oldRule: TxtTocRule? = null) { + fun saveRule(rule: TxtTocRule) { execute { if (rule.serialNumber < 0) { rule.serialNumber = App.db.txtTocRule().lastOrderNum + 1 } - oldRule?.let { - App.db.txtTocRule().delete(oldRule) - } App.db.txtTocRule().insert(rule) } }