diff --git a/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/module/PlatformModule.android.kt b/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/module/PlatformModule.android.kt index ccbdd51d..5486d8b0 100644 --- a/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/module/PlatformModule.android.kt +++ b/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/module/PlatformModule.android.kt @@ -24,6 +24,8 @@ import io.ktor.client.engine.okhttp.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.http.* import io.ktor.serialization.kotlinx.json.* +import io.realm.kotlin.mongodb.App +import io.realm.kotlin.mongodb.AppConfiguration import kotlinx.serialization.json.Json import okio.FileSystem import org.kodein.di.DI @@ -64,6 +66,9 @@ actual object PlatformModule { DriverFactory(instance()) } if (StateSaver.sekretLibraryLoaded) { + bindEagerSingleton { + AppConfiguration.create(Sekret().mongoApplication(getPackageName())!!) + } bindEagerSingleton { Firebase.initialize( context = instance(), diff --git a/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/module/NetworkModule.kt b/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/module/NetworkModule.kt index c5c6a060..1732d2cd 100644 --- a/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/module/NetworkModule.kt +++ b/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/module/NetworkModule.kt @@ -16,6 +16,7 @@ import dev.datlag.burningseries.shared.getPackageName import dev.datlag.burningseries.shared.other.StateSaver import io.ktor.client.* import io.realm.kotlin.mongodb.App +import io.realm.kotlin.mongodb.AppConfiguration import org.kodein.di.* object NetworkModule { @@ -100,7 +101,7 @@ object NetworkModule { } if (StateSaver.sekretLibraryLoaded) { bindEagerSingleton { - App.create(Sekret().mongoApplication(getPackageName())!!) + App.create(instance()) } bindEagerSingleton(TAG_KTORFIT_FIRESTORE) { val builder = instance() diff --git a/app/shared/src/desktopMain/kotlin/dev/datlag/burningseries/shared/module/PlatformModule.desktop.kt b/app/shared/src/desktopMain/kotlin/dev/datlag/burningseries/shared/module/PlatformModule.desktop.kt index 5c57aa32..de6cb2c0 100644 --- a/app/shared/src/desktopMain/kotlin/dev/datlag/burningseries/shared/module/PlatformModule.desktop.kt +++ b/app/shared/src/desktopMain/kotlin/dev/datlag/burningseries/shared/module/PlatformModule.desktop.kt @@ -9,6 +9,7 @@ import coil3.fetch.NetworkFetcher import coil3.memory.MemoryCache import coil3.request.crossfade import dev.datlag.burningseries.database.DriverFactory +import dev.datlag.burningseries.model.common.canWriteSafely import dev.datlag.burningseries.shared.AppIO import dev.datlag.burningseries.shared.Sekret import dev.datlag.burningseries.shared.getPackageName @@ -22,6 +23,8 @@ import io.ktor.client.engine.okhttp.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.http.* import io.ktor.serialization.kotlinx.json.* +import io.realm.kotlin.mongodb.App +import io.realm.kotlin.mongodb.AppConfiguration import kotlinx.serialization.json.Json import okio.FileSystem import org.kodein.di.DI @@ -65,6 +68,18 @@ actual object PlatformModule { DriverFactory(instance("BurningSeriesDBFile")) } if (StateSaver.sekretLibraryLoaded) { + bindEagerSingleton { + AppIO.getWriteableExecutableFolder().let { + if (it.canWriteSafely()) { + AppConfiguration.Builder(Sekret().mongoApplication(getPackageName())!!) + .syncRootDirectory(it.canonicalPath) + .build() + } else { + AppConfiguration.create(Sekret().mongoApplication(getPackageName())!!) + } + } + + } bindEagerSingleton { Firebase.initialize( context = Context(),