mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Close the client before deleting data, and ensure the app is restarted, using a cache Index.
This commit is contained in:
committed by
Benoit Marty
parent
200fe59fbb
commit
979ebe4adb
+4
-2
@@ -339,11 +339,13 @@ class RustMatrixClient constructor(
|
||||
}
|
||||
|
||||
override suspend fun getCacheSize(): Long {
|
||||
return baseDirectory.getCacheSize(userID = client.userId())
|
||||
// Do not use client.userId since it can throw if client has been closed (during clear cache)
|
||||
return baseDirectory.getCacheSize(userID = sessionId.value)
|
||||
}
|
||||
|
||||
override suspend fun clearCache() {
|
||||
baseDirectory.deleteSessionDirectory(userID = client.userId())
|
||||
close()
|
||||
baseDirectory.deleteSessionDirectory(userID = sessionId.value, deleteCryptoDb = false)
|
||||
}
|
||||
|
||||
override suspend fun logout() = withContext(dispatchers.io) {
|
||||
|
||||
+10
@@ -58,6 +58,8 @@ class RustMatrixAuthenticationService @Inject constructor(
|
||||
private val clock: SystemClock,
|
||||
) : MatrixAuthenticationService {
|
||||
|
||||
private val cacheIdxState = MutableStateFlow(0)
|
||||
|
||||
private val authService: RustAuthenticationService = RustAuthenticationService(
|
||||
basePath = baseDirectory.absolutePath,
|
||||
passphrase = null,
|
||||
@@ -71,6 +73,14 @@ class RustMatrixAuthenticationService @Inject constructor(
|
||||
return sessionStore.isLoggedIn()
|
||||
}
|
||||
|
||||
override fun incrementCacheIdx() {
|
||||
cacheIdxState.value++
|
||||
}
|
||||
|
||||
override fun cacheIdx(): Flow<Int> {
|
||||
return cacheIdxState
|
||||
}
|
||||
|
||||
override suspend fun getLatestSessionId(): SessionId? = withContext(coroutineDispatchers.io) {
|
||||
sessionStore.getLatestSession()?.userId?.let { SessionId(it) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user