Skip to content

Commit

Permalink
quick changes in db
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfallet committed Apr 5, 2024
1 parent d98ba5b commit a3d3f29
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package me.nathanfallet.extopy.di

import me.nathanfallet.extopy.BuildConfig
import me.nathanfallet.extopy.database.DatabaseDriverFactory
import me.nathanfallet.extopy.database.IDatabaseDriverFactory
import me.nathanfallet.extopy.models.application.ExtopyEnvironment
import me.nathanfallet.extopy.repositories.application.ITokenRepository
import me.nathanfallet.extopy.repositories.application.TokenRepository
Expand All @@ -15,7 +16,7 @@ val environmentModule = module {
}

val databaseModule = module {
single { DatabaseDriverFactory(get()) }
single<IDatabaseDriverFactory> { DatabaseDriverFactory(get()) }
}

val repositoryModule = module {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ExtopyApplication : Application() {
modules(sharedModule + androidModule)
}
if (!BuildConfig.DEBUG) {
initializeSentry(this)
initializeSentry()
}
}

Expand Down
2 changes: 1 addition & 1 deletion ios/Extopy/DI/ExtopyApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct ExtopyApp: App {
KoinApplication.start()

#if !DEBUG
SentryKt.initializeSentry(context: nil)
SentryKt.initializeSentry()
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import android.content.Context
import app.cash.sqldelight.db.SqlDriver
import app.cash.sqldelight.driver.android.AndroidSqliteDriver

actual class DatabaseDriverFactory(private val context: Context) {
class DatabaseDriverFactory(private val context: Context) : IDatabaseDriverFactory {

actual fun createDriver(): SqlDriver =
override fun createDriver(): SqlDriver =
AndroidSqliteDriver(AppDatabase.Schema, context, "extopy.db")

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.nathanfallet.extopy.database

class Database(databaseDriverFactory: DatabaseDriverFactory) {
class Database(databaseDriverFactory: IDatabaseDriverFactory) {

private val database = AppDatabase(databaseDriverFactory.createDriver())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package me.nathanfallet.extopy.database

import app.cash.sqldelight.db.SqlDriver

expect class DatabaseDriverFactory {
interface IDatabaseDriverFactory {

fun createDriver(): SqlDriver

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package me.nathanfallet.extopy.di

import io.sentry.kotlin.multiplatform.Context
import io.sentry.kotlin.multiplatform.Sentry
import io.sentry.kotlin.multiplatform.SentryOptions

fun initializeSentry(context: Context?) {
fun initializeSentry() {
val configuration: (SentryOptions) -> Unit = {
it.dsn = "https://0c402f45f26b3288980c13a4ef5db57a@o4506105040470016.ingest.sentry.io/4506370995453953"
// Add common configuration here
}
if (context != null) {
Sentry.init(context, configuration)
} else {
Sentry.init(configuration)
}
Sentry.init(configuration)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package me.nathanfallet.extopy.database
import app.cash.sqldelight.db.SqlDriver
import app.cash.sqldelight.driver.native.NativeSqliteDriver

actual class DatabaseDriverFactory {
class DatabaseDriverFactory : IDatabaseDriverFactory {

actual fun createDriver(): SqlDriver =
override fun createDriver(): SqlDriver =
NativeSqliteDriver(AppDatabase.Schema, "extopy.db")

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.nathanfallet.extopy.di

import me.nathanfallet.extopy.database.DatabaseDriverFactory
import me.nathanfallet.extopy.database.IDatabaseDriverFactory
import me.nathanfallet.extopy.models.application.ExtopyEnvironment
import me.nathanfallet.extopy.repositories.application.ITokenRepository

Expand All @@ -10,7 +10,7 @@ object SwiftModule {
lateinit var tokenRepository: ITokenRepository

fun module() = org.koin.dsl.module {
single { DatabaseDriverFactory() }
single<IDatabaseDriverFactory> { DatabaseDriverFactory() }

single { environment }
single { tokenRepository }
Expand Down

0 comments on commit a3d3f29

Please sign in to comment.