pull/35/head^2
kunfei 5 years ago
parent f25a36b8ea
commit 9b6a37e07a
  1. 4
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt
  2. 4
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt

@ -24,7 +24,9 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
fun save(bookSource: BookSource, finally: (() -> Unit)? = null) { fun save(bookSource: BookSource, finally: (() -> Unit)? = null) {
execute { execute {
sourceLiveData.value?.let { sourceLiveData.value?.let {
App.db.bookSourceDao().delete(it) if (it.bookSourceUrl != bookSource.bookSourceUrl) {
App.db.bookSourceDao().delete(it)
}
} ?: let { } ?: let {
bookSource.customOrder = App.db.bookSourceDao().maxOrder + 1 bookSource.customOrder = App.db.bookSourceDao().maxOrder + 1
} }

@ -25,7 +25,9 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
fun save(rssSource: RssSource, success: (() -> Unit)) { fun save(rssSource: RssSource, success: (() -> Unit)) {
execute { execute {
sourceLiveData.value?.let { sourceLiveData.value?.let {
App.db.rssSourceDao().delete(it) if (it.sourceUrl != rssSource.sourceUrl) {
App.db.rssSourceDao().delete(it)
}
} ?: let { } ?: let {
rssSource.customOrder = App.db.rssSourceDao().maxOrder + 1 rssSource.customOrder = App.db.rssSourceDao().maxOrder + 1
} }

Loading…
Cancel
Save