Add comment to explain why we use a AlwaysSuccessfulWorker

This commit is contained in:
Benoit Marty 2019-08-06 15:03:15 +02:00
parent 15c4b03340
commit 4009f2c176
2 changed files with 5 additions and 4 deletions

View file

@ -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<FakeSendWorker>()
// Replace the worker chains with a AlwaysSuccessfulWorker, to ensure the queues are well emptied
matrixOneTimeWorkRequestBuilder<AlwaysSuccessfulWorker>()
.build().let {
TimelineSendEventWorkCommon.postWork(context, roomId, it, ExistingWorkPolicy.REPLACE)

View file

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