From 65088dde5a6ef51452f7e501b1036e18e05ad1b9 Mon Sep 17 00:00:00 2001 From: CalvinKern Date: Mon, 26 Aug 2019 09:09:23 -0600 Subject: [PATCH] [Student][R-6.6.1] Fix success/error from file uploads on assignment deets (#264) The submission wasn't getting deleted/errored correctly for file uploads. --- .../student/mobius/common/ui/SubmissionService.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/student/src/main/java/com/instructure/student/mobius/common/ui/SubmissionService.kt b/apps/student/src/main/java/com/instructure/student/mobius/common/ui/SubmissionService.kt index a45acf3a73..f6f8238145 100644 --- a/apps/student/src/main/java/com/instructure/student/mobius/common/ui/SubmissionService.kt +++ b/apps/student/src/main/java/com/instructure/student/mobius/common/ui/SubmissionService.kt @@ -161,6 +161,7 @@ class SubmissionService : IntentService(SubmissionService::class.java.simpleName } } catch (e: Throwable) { detachForegroundNotification() + db.submissionQueries.setSubmissionError(true, submission.id) showErrorNotification(this@SubmissionService, submission) return@runBlocking } @@ -190,12 +191,13 @@ class SubmissionService : IntentService(SubmissionService::class.java.simpleName val attachmentIds = completed.mapNotNull { it.attachmentId } + uploadedAttachmentIds SubmissionManager.postSubmissionAttachmentsSynchronous(submission.canvasContext.id, submission.assignmentId, attachmentIds)?.let { // Clear out the db for the successful submission - deleteSubmissionsForAssignment(submission.id, db) + deleteSubmissionsForAssignment(submission.assignmentId, db) detachForegroundNotification() showCompleteNotification(this, submission) } ?: run { detachForegroundNotification() + db.submissionQueries.setSubmissionError(true, submission.id) showErrorNotification(this, submission) } } @@ -586,9 +588,9 @@ class SubmissionService : IntentService(SubmissionService::class.java.simpleName FileUploadUtils.deleteTempFile(file.fullPath) } } + db.fileSubmissionQueries.deleteFilesForSubmissionId(submission.id) } db.submissionQueries.deleteSubmissionsForAssignmentId(id, getUserId()) - db.fileSubmissionQueries.deleteFilesForSubmissionId(id) } // region start helpers