Remove unnecessary code and fix signout

This commit is contained in:
ganfra 2019-08-02 13:15:56 +02:00
parent d696bd2830
commit c413321a22
6 changed files with 6 additions and 17 deletions

View file

@ -38,8 +38,4 @@ interface MatrixCallback<in T> {
//no-op
}
fun onCanceled() {
//no-op
}
}

View file

@ -73,7 +73,7 @@ internal class DefaultAuthenticator @Inject constructor(@Unauthenticated
}
sessionOrFailure.foldToCallback(callback)
}
return CancelableCoroutine(job, callback)
return CancelableCoroutine(job)
}

View file

@ -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<Unit> {
override fun onSuccess(data: Unit) {
Timber.w("SIGN_OUT: call webservice -> SUCCESS: clear cache")
stopSync()
stopAnyBackgroundSync()
// Clear the cache
cacheService.get().clearCache(object : MatrixCallback<Unit> {
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) {

View file

@ -134,10 +134,6 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
latch.countDown()
}
override fun onCanceled() {
latch.countDown()
}
})
.executeBy(taskExecutor)
latch.await()

View file

@ -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
}
}

View file

@ -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()
}
}