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. * This method start the sync thread.
*/ */
@MainThread
fun startSync() fun startSync()
/** /**
* This method stop the sync thread. * This method stop the sync thread.
*/ */
@MainThread
fun stopSync() fun stopSync()
/** /**
@ -99,7 +97,6 @@ interface Session :
/** /**
* This method allow to close a session. It does stop some services. * This method allow to close a session. It does stop some services.
*/ */
@MainThread
fun close() fun close()
/** /**

View file

@ -20,6 +20,7 @@ import android.content.Context
import android.os.Looper import android.os.Looper
import androidx.annotation.MainThread import androidx.annotation.MainThread
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.work.WorkManager
import com.zhuinden.monarchy.Monarchy import com.zhuinden.monarchy.Monarchy
import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.auth.data.SessionParams 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) SyncWorker.stopAnyBackgroundSync(context)
} }
@MainThread
override fun startSync() { override fun startSync() {
assert(isOpen) assert(isOpen)
if (!syncThread.isAlive) { if (!syncThread.isAlive) {
@ -113,16 +113,14 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se
} }
} }
@MainThread
override fun stopSync() { override fun stopSync() {
assert(isOpen) assert(isOpen)
syncThread.kill() syncThread.kill()
} }
@MainThread
override fun close() { override fun close() {
assertMainThread()
assert(isOpen) assert(isOpen)
stopSync()
liveEntityObservers.forEach { it.dispose() } liveEntityObservers.forEach { it.dispose() }
cryptoService.close() cryptoService.close()
if (monarchy.isMonarchyThreadOpen) { if (monarchy.isMonarchyThreadOpen) {
@ -153,6 +151,11 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se
override fun onSuccess(data: Unit) { override fun onSuccess(data: Unit) {
Timber.w("SIGN_OUT: clear cache -> SUCCESS: clear crypto cache") Timber.w("SIGN_OUT: clear cache -> SUCCESS: clear crypto cache")
cryptoService.clearCryptoCache(MatrixCallbackDelegate(callback)) cryptoService.clearCryptoCache(MatrixCallbackDelegate(callback))
WorkManager.getInstance(context).also {
it.cancelAllWork()
it.pruneWork()
}
} }
override fun onFailure(failure: Throwable) { override fun onFailure(failure: Throwable) {