package com.app.input.inputaura.ohbnf

import com.app.input.inputaura.dasda.Shikamaru
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

object OpnYty {


    suspend fun addLike(data: Shikamaru) {
        withContext(Dispatchers.IO) {
            DaBase.daBase.ThemesDao().insertData(data)
        }

    }
    suspend fun removeLike(data: Shikamaru) {
        withContext(Dispatchers.IO) {
            val queryIsLike = DaBase.daBase.ThemesDao().queryIsLike(data.titleName)
            if (queryIsLike != null) {
                DaBase.daBase.ThemesDao().delete(queryIsLike)
            }
        }

    }
    suspend fun getIsLike(name: String, action: (isLike: Boolean) -> Unit) {
        withContext(Dispatchers.IO) {
            val query = DaBase.daBase.ThemesDao().queryIsLike(name)
            withContext(Dispatchers.Main) {
                action.invoke(query != null)
            }
        }

    }
}