pull/2676/head
Horis 2 years ago
parent 2d3c2d2134
commit 4aa96fd1aa
  1. 4
      app/src/main/java/io/legado/app/ui/book/group/GroupViewModel.kt

@ -17,12 +17,14 @@ class GroupViewModel(application: Application) : BaseViewModel(application) {
fun addGroup(groupName: String, cover: String?, finally: () -> Unit) { fun addGroup(groupName: String, cover: String?, finally: () -> Unit) {
execute { execute {
val groupId = appDb.bookGroupDao.getUnusedId()
val bookGroup = BookGroup( val bookGroup = BookGroup(
groupId = appDb.bookGroupDao.getUnusedId(), groupId = groupId,
groupName = groupName, groupName = groupName,
cover = cover, cover = cover,
order = appDb.bookGroupDao.maxOrder.plus(1) order = appDb.bookGroupDao.maxOrder.plus(1)
) )
appDb.bookGroupDao.getByID(groupId) ?: appDb.bookDao.removeGroup(groupId)
appDb.bookGroupDao.insert(bookGroup) appDb.bookGroupDao.insert(bookGroup)
}.onFinally { }.onFinally {
finally() finally()

Loading…
Cancel
Save