Merge pull request #258 from vector-im/feature/fix_signout

Fix / signout sign-in not working
This commit is contained in:
Valere 2019-07-01 20:37:32 +02:00 committed by GitHub
commit 8e653979fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -81,13 +81,11 @@ interface Session :
/**
* This method start the sync thread.
*/
@MainThread
fun startSync()

/**
* This method stop the sync thread.
*/
@MainThread
fun stopSync()

/**
@ -99,7 +97,6 @@ interface Session :
/**
* This method allow to close a session. It does stop some services.
*/
@MainThread
fun close()

/**

View File

@ -20,6 +20,7 @@ import android.content.Context
import android.os.Looper
import androidx.annotation.MainThread
import androidx.lifecycle.LiveData
import androidx.work.WorkManager
import com.zhuinden.monarchy.Monarchy
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.auth.data.SessionParams
@ -102,7 +103,6 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se
SyncWorker.stopAnyBackgroundSync(context)
}

@MainThread
override fun startSync() {
assert(isOpen)
if (!syncThread.isAlive) {
@ -113,16 +113,14 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se
}
}

@MainThread
override fun stopSync() {
assert(isOpen)
syncThread.kill()
}

@MainThread
override fun close() {
assertMainThread()
assert(isOpen)
stopSync()
liveEntityObservers.forEach { it.dispose() }
cryptoService.close()
if (monarchy.isMonarchyThreadOpen) {
@ -153,6 +151,11 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se
override fun onSuccess(data: Unit) {
Timber.w("SIGN_OUT: clear cache -> SUCCESS: clear crypto cache")
cryptoService.clearCryptoCache(MatrixCallbackDelegate(callback))

WorkManager.getInstance(context).also {
it.cancelAllWork()
it.pruneWork()
}
}

override fun onFailure(failure: Throwable) {