Skip to content
Snippets Groups Projects
Commit 461a7566 authored by Taras's avatar Taras
Browse files

Fix lazy session init on login

parent bb9a0cd8
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,6 @@ import org.matrix.android.sdk.api.util.awaitCallback ...@@ -14,7 +14,6 @@ import org.matrix.android.sdk.api.util.awaitCallback
class RestorePassPhraseDataSource(private val context: Context) { class RestorePassPhraseDataSource(private val context: Context) {
private val session by lazy { MatrixSessionProvider.currentSession }
val loadingLiveData = MutableLiveData<LoadingData>() val loadingLiveData = MutableLiveData<LoadingData>()
private val passPhraseLoadingData = LoadingData() private val passPhraseLoadingData = LoadingData()
...@@ -46,15 +45,17 @@ class RestorePassPhraseDataSource(private val context: Context) { ...@@ -46,15 +45,17 @@ class RestorePassPhraseDataSource(private val context: Context) {
suspend fun getEncryptionAlgorithm(): String? { suspend fun getEncryptionAlgorithm(): String? {
val keyVersion = awaitCallback { val keyVersion = awaitCallback {
session?.cryptoService()?.keysBackupService()?.getCurrentVersion(it) MatrixSessionProvider.currentSession?.cryptoService()?.keysBackupService()
?.getCurrentVersion(it)
}.toKeysVersionResult() }.toKeysVersionResult()
return keyVersion?.algorithm return keyVersion?.algorithm
} }
suspend fun restoreKeysWithPassPhase(passphrase: String) { suspend fun restoreKeysWithPassPhase(passphrase: String) {
val keysBackupService = session?.cryptoService()?.keysBackupService() val keysBackupService =
?: throw Exception(context.getString(R.string.session_is_not_created)) MatrixSessionProvider.currentSession?.cryptoService()?.keysBackupService()
?: throw Exception(context.getString(R.string.session_is_not_created))
val keyVersion = awaitCallback<KeysBackupLastVersionResult> { val keyVersion = awaitCallback<KeysBackupLastVersionResult> {
keysBackupService.getCurrentVersion(it) keysBackupService.getCurrentVersion(it)
}.toKeysVersionResult() }.toKeysVersionResult()
...@@ -66,7 +67,7 @@ class RestorePassPhraseDataSource(private val context: Context) { ...@@ -66,7 +67,7 @@ class RestorePassPhraseDataSource(private val context: Context) {
keyVersion, keyVersion,
passphrase, passphrase,
null, null,
session?.myUserId, MatrixSessionProvider.currentSession?.myUserId,
progressObserver, progressObserver,
it it
) )
......
...@@ -13,7 +13,6 @@ class CoreSpacesTreeBuilder( ...@@ -13,7 +13,6 @@ class CoreSpacesTreeBuilder(
private val context: Context, private val context: Context,
private val createRoomDataSource: CreateRoomDataSource private val createRoomDataSource: CreateRoomDataSource
) { ) {
private val session by lazy { MatrixSessionProvider.currentSession }
suspend fun createCoreSpacesTree() { suspend fun createCoreSpacesTree() {
createRoomDataSource.createRoom(RootSpace()) createRoomDataSource.createRoom(RootSpace())
...@@ -27,7 +26,7 @@ class CoreSpacesTreeBuilder( ...@@ -27,7 +26,7 @@ class CoreSpacesTreeBuilder(
createRoomDataSource.createRoom(Gallery(), context.getString(R.string.photos)) createRoomDataSource.createRoom(Gallery(), context.getString(R.string.photos))
} }
fun isCirclesHierarchyCreated(): Boolean = session?.roomService() fun isCirclesHierarchyCreated(): Boolean = MatrixSessionProvider.currentSession?.roomService()
?.getRoomSummaries(roomSummaryQueryParams { excludeType = null }) ?.getRoomSummaries(roomSummaryQueryParams { excludeType = null })
?.firstOrNull { summary -> summary.hasTag(ROOT_SPACE_TAG) } != null ?.firstOrNull { summary -> summary.hasTag(ROOT_SPACE_TAG) } != null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment