From fa13863a028239439ecca0f98b7c0a66ba95441b Mon Sep 17 00:00:00 2001 From: "eric.marchand" Date: Tue, 30 Jan 2024 08:26:56 +0100 Subject: [PATCH] After some pending task image upload be sure to update data to send to server fix #12 --- .../com/qmobile/qmobileui/action/utils/ActionHelper.kt | 8 ++++++++ .../qmobileui/activity/mainactivity/MainActivity.kt | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/qmobileui/src/main/java/com/qmobile/qmobileui/action/utils/ActionHelper.kt b/qmobileui/src/main/java/com/qmobile/qmobileui/action/utils/ActionHelper.kt index 7084bdb6..d8f79b12 100644 --- a/qmobileui/src/main/java/com/qmobile/qmobileui/action/utils/ActionHelper.kt +++ b/qmobileui/src/main/java/com/qmobile/qmobileui/action/utils/ActionHelper.kt @@ -86,6 +86,14 @@ object ActionHelper { return map } + fun updateActionContent(actionContent: MutableMap?, + parameters: HashMap? = null, + metaData: HashMap? = null) { + + parameters?.let { actionContent?.put("parameters", parameters) } + metaData?.let { actionContent?.put("metadata", ActionMetaData(metaData)) } + } + fun updateActionContentId(actionContent: MutableMap?) { actionContent?.put("id", UUID.randomUUID().toString()) } diff --git a/qmobileui/src/main/java/com/qmobile/qmobileui/activity/mainactivity/MainActivity.kt b/qmobileui/src/main/java/com/qmobile/qmobileui/activity/mainactivity/MainActivity.kt index 44234e22..ef815341 100644 --- a/qmobileui/src/main/java/com/qmobile/qmobileui/activity/mainactivity/MainActivity.kt +++ b/qmobileui/src/main/java/com/qmobile/qmobileui/activity/mainactivity/MainActivity.kt @@ -950,6 +950,7 @@ class MainActivity : parameterName, UPLOADED_METADATA_STRING ) + // MAYBE reset this to not upload pendingTask.actionInfo.imagesToUpload?.set(parameterName, null) }, onImageFailed = { parameterName, throwable -> pendingTask.actionInfo.metaDataToSubmit?.set( @@ -958,6 +959,9 @@ class MainActivity : ) }, onAllUploadFinished = { + ActionHelper.updateActionContent(pendingTask.actionContent, + parameters = pendingTask.actionInfo.paramsToSubmit, + metaData = pendingTask.actionInfo.metaDataToSubmit) sendAction(pendingTask, pendingTask.actionInfo.tableName) { // Nothing to do }