forked from GitHub-Mirror/riotX-android
Update some dependencies
This commit is contained in:
@ -33,7 +33,7 @@ internal class PruneEventWorker(context: Context,
|
||||
|
||||
override fun doWork(): Result {
|
||||
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
||||
?: return Result.FAILURE
|
||||
?: return Result.failure()
|
||||
|
||||
val result = monarchy.tryTransactionAsync { realm ->
|
||||
params.updateIndexes.forEach { index ->
|
||||
@ -41,7 +41,7 @@ internal class PruneEventWorker(context: Context,
|
||||
pruneEvent(realm, data)
|
||||
}
|
||||
}
|
||||
return result.fold({ Result.RETRY }, { Result.SUCCESS })
|
||||
return result.fold({ Result.retry() }, { Result.success() })
|
||||
}
|
||||
|
||||
private fun pruneEvent(realm: Realm, redactionEvent: Event?) {
|
||||
|
@ -15,7 +15,6 @@ import im.vector.matrix.android.internal.session.group.model.GroupSummaryRespons
|
||||
import im.vector.matrix.android.internal.session.group.model.GroupUsers
|
||||
import im.vector.matrix.android.internal.util.CancelableCoroutine
|
||||
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
|
||||
import im.vector.matrix.android.internal.util.retry
|
||||
import im.vector.matrix.android.internal.util.tryTransactionSync
|
||||
import io.realm.kotlin.createObject
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
@ -31,7 +30,7 @@ internal class GetGroupDataRequest(
|
||||
callback: MatrixCallback<Boolean>
|
||||
): Cancelable {
|
||||
val job = GlobalScope.launch(coroutineDispatchers.main) {
|
||||
val groupOrFailure = retry { getGroupData(groupId) }
|
||||
val groupOrFailure = getGroupData(groupId)
|
||||
groupOrFailure.fold({ callback.onFailure(it) }, { callback.onSuccess(true) })
|
||||
}
|
||||
return CancelableCoroutine(job)
|
||||
|
@ -24,14 +24,14 @@ internal class GetGroupDataWorker(context: Context,
|
||||
|
||||
override fun doWork(): Result {
|
||||
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
||||
?: return Result.FAILURE
|
||||
?: return Result.failure()
|
||||
|
||||
val results = params.updateIndexes.map { index ->
|
||||
val groupId = params.groupIds[index]
|
||||
fetchGroupData(groupId)
|
||||
}
|
||||
val isSuccessful = results.none { it.isFailure() }
|
||||
return if (isSuccessful) Result.SUCCESS else Result.RETRY
|
||||
return if (isSuccessful) Result.success() else Result.retry()
|
||||
}
|
||||
|
||||
private fun fetchGroupData(groupId: String): Try<Unit> {
|
||||
|
@ -1,6 +1,11 @@
|
||||
package im.vector.matrix.android.internal.session.room.send
|
||||
|
||||
import androidx.work.*
|
||||
import androidx.work.BackoffPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
@ -32,7 +37,7 @@ internal class DefaultSendService(private val roomId: String,
|
||||
|
||||
monarchy.tryTransactionAsync { realm ->
|
||||
val chunkEntity = ChunkEntity.findLastLiveChunkFromRoom(realm, roomId)
|
||||
?: return@tryTransactionAsync
|
||||
?: return@tryTransactionAsync
|
||||
chunkEntity.add(event, PaginationDirection.FORWARDS)
|
||||
chunkEntity.updateDisplayIndexes()
|
||||
}
|
||||
@ -46,11 +51,11 @@ internal class DefaultSendService(private val roomId: String,
|
||||
.setBackoffCriteria(BackoffPolicy.LINEAR, 10_000, TimeUnit.MILLISECONDS)
|
||||
.build()
|
||||
|
||||
val work = WorkManager.getInstance()
|
||||
WorkManager.getInstance()
|
||||
.beginUniqueWork(SEND_WORK, ExistingWorkPolicy.APPEND, sendWork)
|
||||
.enqueue()
|
||||
|
||||
return CancelableWork(work)
|
||||
return CancelableWork(sendWork.id)
|
||||
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,10 @@ internal class SendEventWorker(context: Context, params: WorkerParameters)
|
||||
override fun doWork(): Result {
|
||||
|
||||
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
||||
?: return Result.FAILURE
|
||||
?: return Result.failure()
|
||||
|
||||
if (params.event.eventId == null) {
|
||||
return Result.FAILURE
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
val result = executeRequest<SendResponse> {
|
||||
@ -51,7 +51,7 @@ internal class SendEventWorker(context: Context, params: WorkerParameters)
|
||||
dummyEventEntity?.eventId = sendResponse.eventId
|
||||
}
|
||||
}
|
||||
return result.fold({ Result.RETRY }, { Result.SUCCESS })
|
||||
return result.fold({ Result.retry() }, { Result.success() })
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package im.vector.matrix.android.internal.util
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import androidx.work.WorkManager
|
||||
import im.vector.matrix.android.api.util.Cancelable
|
||||
import kotlinx.coroutines.Job
|
||||
import java.util.*
|
||||
|
||||
internal class CancelableWork(private val work: ListenableFuture<Void>) : Cancelable {
|
||||
internal class CancelableWork(private val workId: UUID) : Cancelable {
|
||||
|
||||
override fun cancel() {
|
||||
work.cancel(true)
|
||||
WorkManager.getInstance().cancelWorkById(workId)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user