Merge pull request #7397 from thunderbird/fix_koin_setup

Fix Koin setup
This commit is contained in:
Wolf-Martell Montwé 2023-12-01 17:34:23 +00:00 committed by GitHub
commit f2259c3fb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 5 deletions

View file

@ -10,6 +10,7 @@ class FeatureApplication : Application() {
super.onCreate()
startKoin {
allowOverride(false)
androidContext(this@FeatureApplication)
modules(featureModule)
}

View file

@ -11,6 +11,7 @@ class CatalogApplication : Application() {
super.onCreate()
startKoin {
allowOverride(false)
androidContext(this@CatalogApplication)
modules(catalogUiModule)
}

View file

@ -15,8 +15,10 @@ object DI {
private const val DEBUG = false
@JvmStatic
fun start(application: Application, modules: List<Module>) {
fun start(application: Application, modules: List<Module>, allowOverride: Boolean = false) {
startKoin {
allowOverride(allowOverride)
if (BuildConfig.DEBUG && DEBUG) {
androidLogger()
}

View file

@ -10,7 +10,6 @@ import com.fsck.k9.mail.ssl.TrustedSocketFactory
import com.fsck.k9.mailstore.LocalStoreProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.GlobalScope
import kotlinx.datetime.Clock
import org.koin.core.qualifier.named
import org.koin.dsl.module
@ -32,7 +31,6 @@ val mainModule = module {
single { TrustManagerFactory.createInstance(get()) }
single { LocalKeyStoreManager(get()) }
single<TrustedSocketFactory> { DefaultTrustedSocketFactory(get(), get()) }
single<Clock> { Clock.System }
factory { EmailAddressValidator() }
factory { ServerSettingsSerializer() }
}

View file

@ -20,7 +20,11 @@ class TestApp : Application() {
Core.earlyInit()
super.onCreate()
DI.start(this, coreModules + storageModule + testModule)
DI.start(
application = this,
modules = coreModules + storageModule + testModule,
allowOverride = true,
)
K9.init(this)
Core.init(this)

View file

@ -11,7 +11,11 @@ class TestApp : Application() {
Core.earlyInit()
super.onCreate()
DI.start(this, coreModules + storageModule + testModule)
DI.start(
application = this,
modules = coreModules + storageModule + testModule,
allowOverride = true,
)
K9.init(this)
Core.init(this)