Idx -> Index

This commit is contained in:
Benoit Marty 2023-06-23 15:20:19 +02:00 committed by Benoit Marty
parent fc61d452c6
commit b563b1ec95
5 changed files with 17 additions and 17 deletions

View file

@ -91,8 +91,8 @@ class RootFlowNode @AssistedInject constructor(
authenticationService.isLoggedIn() authenticationService.isLoggedIn()
.distinctUntilChanged() .distinctUntilChanged()
.combine( .combine(
authenticationService.cacheIdx().onEach { authenticationService.cacheIndex().onEach {
Timber.v("cacheIdx=$it") Timber.v("cacheIndex=$it")
matrixClientsHolder.removeAll() matrixClientsHolder.removeAll()
} }
) { isLoggedIn, cacheIdx -> isLoggedIn to cacheIdx } ) { isLoggedIn, cacheIdx -> isLoggedIn to cacheIdx }
@ -243,9 +243,9 @@ class RootFlowNode @AssistedInject constructor(
} }
private suspend fun attachSession(sessionId: SessionId): LoggedInFlowNode { private suspend fun attachSession(sessionId: SessionId): LoggedInFlowNode {
val cacheIdx = authenticationService.cacheIdx().first() val cacheIndex = authenticationService.cacheIndex().first()
return attachChild { return attachChild {
backstack.newRoot(NavTarget.LoggedInFlow(sessionId, cacheIdx)) backstack.newRoot(NavTarget.LoggedInFlow(sessionId, cacheIndex))
} }
} }
} }

View file

@ -57,6 +57,6 @@ class DefaultClearCacheUseCase @Inject constructor(
// Clear app cache // Clear app cache
context.cacheDir.deleteRecursively() context.cacheDir.deleteRecursively()
// Ensure the app is restarted // Ensure the app is restarted
authenticationService.incrementCacheIdx() authenticationService.incrementCacheIndex()
} }
} }

View file

@ -33,8 +33,8 @@ interface MatrixAuthenticationService {
* Cache index * Cache index
*/ */
fun cacheIdx(): Flow<Int> fun cacheIndex(): Flow<Int>
fun incrementCacheIdx() fun incrementCacheIndex()
/* /*
* OIDC part. * OIDC part.

View file

@ -58,7 +58,7 @@ class RustMatrixAuthenticationService @Inject constructor(
private val clock: SystemClock, private val clock: SystemClock,
) : MatrixAuthenticationService { ) : MatrixAuthenticationService {
private val cacheIdxState = MutableStateFlow(0) private val cacheIndexState = MutableStateFlow(0)
private val authService: RustAuthenticationService = RustAuthenticationService( private val authService: RustAuthenticationService = RustAuthenticationService(
basePath = baseDirectory.absolutePath, basePath = baseDirectory.absolutePath,
@ -73,12 +73,12 @@ class RustMatrixAuthenticationService @Inject constructor(
return sessionStore.isLoggedIn() return sessionStore.isLoggedIn()
} }
override fun incrementCacheIdx() { override fun incrementCacheIndex() {
cacheIdxState.value++ cacheIndexState.value++
} }
override fun cacheIdx(): Flow<Int> { override fun cacheIndex(): Flow<Int> {
return cacheIdxState return cacheIndexState
} }
override suspend fun getLatestSessionId(): SessionId? = withContext(coroutineDispatchers.io) { override suspend fun getLatestSessionId(): SessionId? = withContext(coroutineDispatchers.io) {

View file

@ -65,14 +65,14 @@ class FakeAuthenticationService : MatrixAuthenticationService {
loginError?.let { Result.failure(it) } ?: Result.success(A_USER_ID) loginError?.let { Result.failure(it) } ?: Result.success(A_USER_ID)
} }
private val cacheIdxFlow = MutableStateFlow(0) private val cacheIndexFlow = MutableStateFlow(0)
override fun cacheIdx(): Flow<Int> { override fun cacheIndex(): Flow<Int> {
return cacheIdxFlow return cacheIndexFlow
} }
override fun incrementCacheIdx() { override fun incrementCacheIndex() {
cacheIdxFlow.value++ cacheIndexFlow.value++
} }
override suspend fun getOidcUrl(): Result<OidcDetails> = simulateLongTask { override suspend fun getOidcUrl(): Result<OidcDetails> = simulateLongTask {