mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
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
|
||||
}
|
||||
|
||||
fun onCanceled() {
|
||||
//no-op
|
||||
}
|
||||
|
||||
}
|
@ -73,7 +73,7 @@ internal class DefaultAuthenticator @Inject constructor(@Unauthenticated
|
||||
}
|
||||
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")
|
||||
|
||||
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) {
|
||||
|
@ -134,10 +134,6 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
|
||||
latch.countDown()
|
||||
}
|
||||
|
||||
override fun onCanceled() {
|
||||
latch.countDown()
|
||||
}
|
||||
|
||||
})
|
||||
.executeBy(taskExecutor)
|
||||
latch.await()
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user