Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Rename providesRepository to provideRepository in dagger module n…
Browse files Browse the repository at this point in the history
…amed `DatabaseProvider`
  • Loading branch information
M3DZIK committed Jul 4, 2024
1 parent 06df388 commit d94ad0e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ suspend fun syncCiphers(
) {
val currentTimeSeconds = TimeUnit.MILLISECONDS.toSeconds(Date().time)

val repository = DatabaseProvider.providesRepository(context)
val repository = DatabaseProvider.provideRepository(context)

val localCiphers = repository.cipher.getAll(credentials.userId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import dev.medzik.librepass.android.business.VaultCache
import dev.medzik.librepass.android.database.LocalCipherDao
import dev.medzik.librepass.android.database.Repository
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object VaultCacheModule {
@Singleton
@Provides
fun providesVault(cipherRepository: LocalCipherDao): VaultCache {
return VaultCache(cipherRepository)
fun providesVault(repository: Repository): VaultCache {
return VaultCache(repository)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import javax.inject.Singleton
object DatabaseProvider {
@Singleton
@Provides
fun providesRepository(@ApplicationContext context: Context): Repository {
fun provideRepository(@ApplicationContext context: Context): Repository {
return Repository(context)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object Home
@Composable
fun HomeScreen(navController: NavController) {
val context = LocalContext.current
val repository = DatabaseProvider.providesRepository(context)
val repository = DatabaseProvider.provideRepository(context)
val credentials = repository.credentials.get()

if (credentials != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fun ChoiceServer(server: MutableState<String>) {
var servers by rememberMutable(emptyList<CustomServer>())

LaunchedEffect(Unit) {
val repository = DatabaseProvider.providesRepository(context)
val repository = DatabaseProvider.provideRepository(context)

val customServers = repository.customServer.getAll()

Expand Down Expand Up @@ -142,7 +142,7 @@ fun AddServerSheetContent(

val scope = rememberCoroutineScope()

val repository = DatabaseProvider.providesRepository(context)
val repository = DatabaseProvider.provideRepository(context)

var customServer by rememberMutable(
CustomServer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class LoginViewModel : ViewModel() {
password = password.value
)

val repository = DatabaseProvider.providesRepository(context)
val vaultCache = VaultCacheModule.providesVault(repository.cipher)
val repository = DatabaseProvider.provideRepository(context)
val vaultCache = VaultCacheModule.providesVault(repository)

val credentialsDbEntry = Credentials(
userId = credentials.userId,
Expand Down

0 comments on commit d94ad0e

Please sign in to comment.