mirror of
https://github.com/bitwarden/android.git
synced 2026-06-05 04:06:34 -05:00
Use the clock in the Generator Repo (#1032)
This commit is contained in:
committed by
Álison Fernandes
parent
7558a29922
commit
32f9b1bde6
@@ -40,7 +40,7 @@ import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import java.time.Instant
|
||||
import java.time.Clock
|
||||
import javax.inject.Singleton
|
||||
import kotlin.math.max
|
||||
|
||||
@@ -50,6 +50,7 @@ import kotlin.math.max
|
||||
@Singleton
|
||||
@Suppress("LongParameterList")
|
||||
class GeneratorRepositoryImpl(
|
||||
private val clock: Clock,
|
||||
private val generatorSdkSource: GeneratorSdkSource,
|
||||
private val generatorDiskSource: GeneratorDiskSource,
|
||||
private val authDiskSource: AuthDiskSource,
|
||||
@@ -119,7 +120,7 @@ class GeneratorRepositoryImpl(
|
||||
onSuccess = { generatedPassword ->
|
||||
val passwordHistoryView = PasswordHistoryView(
|
||||
password = generatedPassword,
|
||||
lastUsedDate = Instant.now(),
|
||||
lastUsedDate = clock.instant(),
|
||||
)
|
||||
|
||||
if (shouldSave) {
|
||||
@@ -141,7 +142,7 @@ class GeneratorRepositoryImpl(
|
||||
onSuccess = { generatedPassphrase ->
|
||||
val passwordHistoryView = PasswordHistoryView(
|
||||
password = generatedPassphrase,
|
||||
lastUsedDate = Instant.now(),
|
||||
lastUsedDate = clock.instant(),
|
||||
)
|
||||
scope.launch {
|
||||
storePasswordHistory(passwordHistoryView)
|
||||
|
||||
@@ -13,6 +13,7 @@ import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import java.time.Clock
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
@@ -25,6 +26,7 @@ object GeneratorRepositoryModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideGeneratorRepository(
|
||||
clock: Clock,
|
||||
generatorSdkSource: GeneratorSdkSource,
|
||||
generatorDiskSource: GeneratorDiskSource,
|
||||
authDiskSource: AuthDiskSource,
|
||||
@@ -33,6 +35,7 @@ object GeneratorRepositoryModule {
|
||||
dispatcherManager: DispatcherManager,
|
||||
policyManager: PolicyManager,
|
||||
): GeneratorRepository = GeneratorRepositoryImpl(
|
||||
clock = clock,
|
||||
generatorSdkSource = generatorSdkSource,
|
||||
generatorDiskSource = generatorDiskSource,
|
||||
authDiskSource = authDiskSource,
|
||||
|
||||
Reference in New Issue
Block a user