优化
This commit is contained in:
1 parent
d9a6da7b45
commit
367232459a
1 file changed
+3
-1
@@ -17,12 +17,14 @@ class GroupViewModel(application: Application) : BaseViewModel(application) {
|
||||
|
||||
fun addGroup(groupName: String, cover: String?, finally: () -> Unit) {
|
||||
execute {
|
||||
val groupId = appDb.bookGroupDao.getUnusedId()
|
||||
val bookGroup = BookGroup(
|
||||
groupId = appDb.bookGroupDao.getUnusedId(),
|
||||
groupId = groupId,
|
||||
groupName = groupName,
|
||||
cover = cover,
|
||||
order = appDb.bookGroupDao.maxOrder.plus(1)
|
||||
)
|
||||
appDb.bookGroupDao.getByID(groupId) ?: appDb.bookDao.removeGroup(groupId)
|
||||
appDb.bookGroupDao.insert(bookGroup)
|
||||
}.onFinally {
|
||||
finally()
|
||||
|
||||
Reference in new issue
Block a user