Move cache management to a dedicated class and in the setting module, for clarity.
This commit is contained in:
parent
cc1c3c8f7b
commit
b6920afb7f
7 changed files with 74 additions and 32 deletions
|
|
@ -29,13 +29,6 @@ interface MatrixAuthenticationService {
|
|||
suspend fun setHomeserver(homeserver: String): Result<Unit>
|
||||
suspend fun login(username: String, password: String): Result<SessionId>
|
||||
|
||||
/*
|
||||
* Cache index
|
||||
*/
|
||||
|
||||
fun cacheIndex(): Flow<Int>
|
||||
fun incrementCacheIndex()
|
||||
|
||||
/*
|
||||
* OIDC part.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@ class RustMatrixAuthenticationService @Inject constructor(
|
|||
private val clock: SystemClock,
|
||||
) : MatrixAuthenticationService {
|
||||
|
||||
private val cacheIndexState = MutableStateFlow(0)
|
||||
|
||||
private val authService: RustAuthenticationService = RustAuthenticationService(
|
||||
basePath = baseDirectory.absolutePath,
|
||||
passphrase = null,
|
||||
|
|
@ -73,14 +71,6 @@ class RustMatrixAuthenticationService @Inject constructor(
|
|||
return sessionStore.isLoggedIn()
|
||||
}
|
||||
|
||||
override fun incrementCacheIndex() {
|
||||
cacheIndexState.value++
|
||||
}
|
||||
|
||||
override fun cacheIndex(): Flow<Int> {
|
||||
return cacheIndexState
|
||||
}
|
||||
|
||||
override suspend fun getLatestSessionId(): SessionId? = withContext(coroutineDispatchers.io) {
|
||||
sessionStore.getLatestSession()?.userId?.let { SessionId(it) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,16 +65,6 @@ class FakeAuthenticationService : MatrixAuthenticationService {
|
|||
loginError?.let { Result.failure(it) } ?: Result.success(A_USER_ID)
|
||||
}
|
||||
|
||||
private val cacheIndexFlow = MutableStateFlow(0)
|
||||
|
||||
override fun cacheIndex(): Flow<Int> {
|
||||
return cacheIndexFlow
|
||||
}
|
||||
|
||||
override fun incrementCacheIndex() {
|
||||
cacheIndexFlow.value++
|
||||
}
|
||||
|
||||
override suspend fun getOidcUrl(): Result<OidcDetails> = simulateLongTask {
|
||||
oidcError?.let { Result.failure(it) } ?: Result.success(A_OIDC_DATA)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue