From c413321a224d4eb88b16efad0892649db96f21b5 Mon Sep 17 00:00:00 2001 From: ganfra Date: Fri, 2 Aug 2019 13:15:56 +0200 Subject: [PATCH] Remove unnecessary code and fix signout --- .../java/im/vector/matrix/android/api/MatrixCallback.kt | 4 ---- .../matrix/android/internal/auth/DefaultAuthenticator.kt | 2 +- .../matrix/android/internal/session/DefaultSession.kt | 7 +++---- .../matrix/android/internal/session/sync/job/SyncThread.kt | 4 ---- .../im/vector/matrix/android/internal/task/TaskExecutor.kt | 2 +- .../matrix/android/internal/util/CancelableCoroutine.kt | 4 +--- 6 files changed, 6 insertions(+), 17 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixCallback.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixCallback.kt index e907bb25..00d22b1f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixCallback.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixCallback.kt @@ -38,8 +38,4 @@ interface MatrixCallback { //no-op } - fun onCanceled() { - //no-op - } - } \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/DefaultAuthenticator.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/DefaultAuthenticator.kt index e96aa47b..adea7c89 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/DefaultAuthenticator.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/DefaultAuthenticator.kt @@ -73,7 +73,7 @@ internal class DefaultAuthenticator @Inject constructor(@Unauthenticated } sessionOrFailure.foldToCallback(callback) } - return CancelableCoroutine(job, callback) + return CancelableCoroutine(job) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt index cc68c087..2922b7d6 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt @@ -149,21 +149,20 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se Timber.w("SIGN_OUT: start") assert(isOpen) - //Timber.w("SIGN_OUT: kill sync thread") - //syncThread.kill() Timber.w("SIGN_OUT: call webservice") return signOutService.get().signOut(object : MatrixCallback { override fun onSuccess(data: Unit) { Timber.w("SIGN_OUT: call webservice -> SUCCESS: clear cache") - + stopSync() + stopAnyBackgroundSync() // Clear the cache cacheService.get().clearCache(object : MatrixCallback { override fun onSuccess(data: Unit) { Timber.w("SIGN_OUT: clear cache -> SUCCESS: clear crypto cache") cryptoService.get().clearCryptoCache(MatrixCallbackDelegate(callback)) - WorkManagerUtil.cancelAllWorks(context) + callback.onSuccess(Unit) } override fun onFailure(failure: Throwable) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt index 80c54ddc..6e609bd8 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt @@ -134,10 +134,6 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, latch.countDown() } - override fun onCanceled() { - latch.countDown() - } - }) .executeBy(taskExecutor) latch.await() diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/task/TaskExecutor.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/task/TaskExecutor.kt index a4e6dc5a..61097987 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/task/TaskExecutor.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/task/TaskExecutor.kt @@ -53,7 +53,7 @@ internal class TaskExecutor @Inject constructor(private val coroutineDispatchers } .foldToCallback(task.callback) } - return CancelableCoroutine(job, task.callback).also { + return CancelableCoroutine(job).also { cancelableBag += it } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableCoroutine.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableCoroutine.kt index f5b93eb3..97b8cd0e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableCoroutine.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableCoroutine.kt @@ -16,16 +16,14 @@ package im.vector.matrix.android.internal.util -import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.util.Cancelable import kotlinx.coroutines.Job -internal class CancelableCoroutine(private val job: Job, private val callback: MatrixCallback<*>) : Cancelable { +internal class CancelableCoroutine(private val job: Job) : Cancelable { override fun cancel() { if (!job.isCancelled) { job.cancel() - callback.onCanceled() } }