package com.anypreta.bountyboard

import android.app.Application
import com.anypreta.bountyboard.data.AppContainer
import com.anypreta.bountyboard.data.SettingsStore
import com.anypreta.bountyboard.data.push.PushNotifier
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking

class BountyBoardApp : Application() {

    lateinit var container: AppContainer
        private set

    override fun onCreate() {
        super.onCreate()
        val initialBaseUrl = runBlocking {
            SettingsStore(this@BountyBoardApp).baseUrl.first()
        }
        container = AppContainer(this, initialBaseUrl)
        PushNotifier.ensureChannels(this)
    }
}
