diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt index 1d8eaf3f..b4759c41 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/DefaultSendService.kt @@ -38,6 +38,7 @@ import im.vector.matrix.android.internal.database.query.where import im.vector.matrix.android.internal.session.content.UploadContentWorker import im.vector.matrix.android.internal.session.room.timeline.TimelineSendEventWorkCommon import im.vector.matrix.android.internal.util.CancelableWork +import im.vector.matrix.android.internal.worker.AlwaysSuccessfulWorker import im.vector.matrix.android.internal.worker.WorkManagerUtil import im.vector.matrix.android.internal.worker.WorkManagerUtil.matrixOneTimeWorkRequestBuilder import im.vector.matrix.android.internal.worker.WorkerParamsFactory @@ -163,8 +164,8 @@ internal class DefaultSendService @Inject constructor(private val context: Conte TimelineSendEventWorkCommon.cancelAllWorks(context, roomId) WorkManager.getInstance(context).cancelUniqueWork(buildWorkName(UPLOAD_WORK)) - // TODO Valere: what is the aim of this code ? Cancellation above is not enough? - matrixOneTimeWorkRequestBuilder() + // Replace the worker chains with a AlwaysSuccessfulWorker, to ensure the queues are well emptied + matrixOneTimeWorkRequestBuilder() .build().let { TimelineSendEventWorkCommon.postWork(context, roomId, it, ExistingWorkPolicy.REPLACE) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/FakeSendWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/worker/AlwaysSuccessfulWorker.kt similarity index 85% rename from matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/FakeSendWorker.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/worker/AlwaysSuccessfulWorker.kt index f62c42d0..c0cae10d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/FakeSendWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/worker/AlwaysSuccessfulWorker.kt @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.android.internal.session.room.send +package im.vector.matrix.android.internal.worker import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters -internal class FakeSendWorker(context: Context, params: WorkerParameters) +internal class AlwaysSuccessfulWorker(context: Context, params: WorkerParameters) : Worker(context, params) { override fun doWork(): Result {