mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 21:07:04 +05:30
fix(database): ensure DB is only opened once
Fixes COMPOSE-LOBSTERS-3S
This commit is contained in:
parent
e808e77ab8
commit
6d3e749ad6
1 changed files with 5 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright © 2021-2023 Harsh Shandilya.
|
* Copyright © 2021-2024 Harsh Shandilya.
|
||||||
* Use of this source code is governed by an MIT-style
|
* Use of this source code is governed by an MIT-style
|
||||||
* license that can be found in the LICENSE file or at
|
* license that can be found in the LICENSE file or at
|
||||||
* https://opensource.org/licenses/MIT.
|
* https://opensource.org/licenses/MIT.
|
||||||
|
@ -13,6 +13,7 @@ import app.cash.sqldelight.logs.LogSqliteDriver
|
||||||
import com.deliveryhero.whetstone.app.ApplicationScope
|
import com.deliveryhero.whetstone.app.ApplicationScope
|
||||||
import com.squareup.anvil.annotations.ContributesTo
|
import com.squareup.anvil.annotations.ContributesTo
|
||||||
import com.squareup.anvil.annotations.optional.ForScope
|
import com.squareup.anvil.annotations.optional.ForScope
|
||||||
|
import com.squareup.anvil.annotations.optional.SingleIn
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dev.msfjarvis.claw.database.LobstersDatabase
|
import dev.msfjarvis.claw.database.LobstersDatabase
|
||||||
|
@ -28,7 +29,9 @@ object DatabaseModule {
|
||||||
|
|
||||||
private const val LOBSTERS_DATABASE_NAME = "SavedPosts.db"
|
private const val LOBSTERS_DATABASE_NAME = "SavedPosts.db"
|
||||||
|
|
||||||
@[Provides InternalDatabaseApi]
|
@Provides
|
||||||
|
@InternalDatabaseApi
|
||||||
|
@SingleIn(ApplicationScope::class)
|
||||||
fun provideDatabase(@ForScope(ApplicationScope::class) context: Context): LobstersDatabase {
|
fun provideDatabase(@ForScope(ApplicationScope::class) context: Context): LobstersDatabase {
|
||||||
val driver =
|
val driver =
|
||||||
LogSqliteDriver(
|
LogSqliteDriver(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue