forked from GitHub-Mirror/riotX-android
Remove unnecessary code and fix signout
This commit is contained in:
parent
d696bd2830
commit
c413321a22
@ -38,8 +38,4 @@ interface MatrixCallback<in T> {
|
|||||||
//no-op
|
//no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onCanceled() {
|
|
||||||
//no-op
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -73,7 +73,7 @@ internal class DefaultAuthenticator @Inject constructor(@Unauthenticated
|
|||||||
}
|
}
|
||||||
sessionOrFailure.foldToCallback(callback)
|
sessionOrFailure.foldToCallback(callback)
|
||||||
}
|
}
|
||||||
return CancelableCoroutine(job, callback)
|
return CancelableCoroutine(job)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,21 +149,20 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se
|
|||||||
Timber.w("SIGN_OUT: start")
|
Timber.w("SIGN_OUT: start")
|
||||||
|
|
||||||
assert(isOpen)
|
assert(isOpen)
|
||||||
//Timber.w("SIGN_OUT: kill sync thread")
|
|
||||||
//syncThread.kill()
|
|
||||||
|
|
||||||
Timber.w("SIGN_OUT: call webservice")
|
Timber.w("SIGN_OUT: call webservice")
|
||||||
return signOutService.get().signOut(object : MatrixCallback<Unit> {
|
return signOutService.get().signOut(object : MatrixCallback<Unit> {
|
||||||
override fun onSuccess(data: Unit) {
|
override fun onSuccess(data: Unit) {
|
||||||
Timber.w("SIGN_OUT: call webservice -> SUCCESS: clear cache")
|
Timber.w("SIGN_OUT: call webservice -> SUCCESS: clear cache")
|
||||||
|
stopSync()
|
||||||
|
stopAnyBackgroundSync()
|
||||||
// Clear the cache
|
// Clear the cache
|
||||||
cacheService.get().clearCache(object : MatrixCallback<Unit> {
|
cacheService.get().clearCache(object : MatrixCallback<Unit> {
|
||||||
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.get().clearCryptoCache(MatrixCallbackDelegate(callback))
|
cryptoService.get().clearCryptoCache(MatrixCallbackDelegate(callback))
|
||||||
|
|
||||||
WorkManagerUtil.cancelAllWorks(context)
|
WorkManagerUtil.cancelAllWorks(context)
|
||||||
|
callback.onSuccess(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
|
@ -134,10 +134,6 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
|
|||||||
latch.countDown()
|
latch.countDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCanceled() {
|
|
||||||
latch.countDown()
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.executeBy(taskExecutor)
|
.executeBy(taskExecutor)
|
||||||
latch.await()
|
latch.await()
|
||||||
|
@ -53,7 +53,7 @@ internal class TaskExecutor @Inject constructor(private val coroutineDispatchers
|
|||||||
}
|
}
|
||||||
.foldToCallback(task.callback)
|
.foldToCallback(task.callback)
|
||||||
}
|
}
|
||||||
return CancelableCoroutine(job, task.callback).also {
|
return CancelableCoroutine(job).also {
|
||||||
cancelableBag += it
|
cancelableBag += it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,16 +16,14 @@
|
|||||||
|
|
||||||
package im.vector.matrix.android.internal.util
|
package im.vector.matrix.android.internal.util
|
||||||
|
|
||||||
import im.vector.matrix.android.api.MatrixCallback
|
|
||||||
import im.vector.matrix.android.api.util.Cancelable
|
import im.vector.matrix.android.api.util.Cancelable
|
||||||
import kotlinx.coroutines.Job
|
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() {
|
override fun cancel() {
|
||||||
if (!job.isCancelled) {
|
if (!job.isCancelled) {
|
||||||
job.cancel()
|
job.cancel()
|
||||||
callback.onCanceled()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user