package com.isidroid.c23.domain.use_case

import android.content.Context
import androidx.core.app.ActivityCompat
import com.isidroid.c23.ext.hasNotificationPermission
import com.isidroid.spot.model.RichSpot
import com.isidroid.spot.repository.ActiveSpotRepository
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.flow
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class ContentUseCase @Inject constructor(
    @ApplicationContext private val context: Context,
    private val activeSpotRepository: ActiveSpotRepository
) {
    fun create() = flow {
        val spot = activeSpotRepository.getDefaultSpot()
        val hasNotificationPermission = context.hasNotificationPermission.takeIf { spot != null }

        emit(Pair(spot, hasNotificationPermission))
    }
}