这扯不扯
This commit is contained in:
@@ -18,7 +18,6 @@ import io.legado.app.utils.isJsonObject
|
|||||||
import io.legado.app.utils.sendToClip
|
import io.legado.app.utils.sendToClip
|
||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.update
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class TxtTocRuleViewModel(
|
class TxtTocRuleViewModel(
|
||||||
@@ -64,7 +63,7 @@ class TxtTocRuleViewModel(
|
|||||||
}
|
}
|
||||||
is TxtTocRuleIntent.MoveItem -> moveItemInList(intent.from, intent.to)
|
is TxtTocRuleIntent.MoveItem -> moveItemInList(intent.from, intent.to)
|
||||||
TxtTocRuleIntent.SaveSortOrder -> saveSortOrder()
|
TxtTocRuleIntent.SaveSortOrder -> saveSortOrder()
|
||||||
is TxtTocRuleIntent.SaveRule -> save(intent.rule)
|
is TxtTocRuleIntent.SaveRule -> save(intent.rule, intent.isNew)
|
||||||
is TxtTocRuleIntent.DeleteRule -> delete(intent.rule)
|
is TxtTocRuleIntent.DeleteRule -> delete(intent.rule)
|
||||||
is TxtTocRuleIntent.SetRuleEnabled -> update(intent.rule.copy(enable = intent.enabled))
|
is TxtTocRuleIntent.SetRuleEnabled -> update(intent.rule.copy(enable = intent.enabled))
|
||||||
is TxtTocRuleIntent.CopyRule -> copyRule(intent.rule)
|
is TxtTocRuleIntent.CopyRule -> copyRule(intent.rule)
|
||||||
@@ -114,9 +113,9 @@ class TxtTocRuleViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun save(rule: TxtTocRule) {
|
private fun save(rule: TxtTocRule, isNew: Boolean) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (rule.id == 0L) {
|
if (isNew) {
|
||||||
repository.insert(rule)
|
repository.insert(rule)
|
||||||
} else {
|
} else {
|
||||||
repository.update(rule)
|
repository.update(rule)
|
||||||
|
|||||||
Reference in New Issue
Block a user