优化
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user