@overmap-ai/core 1.0.62-store-clear-fixes.0 → 1.0.62-store-clear-fixes.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/overmap-core.js
CHANGED
|
@@ -2522,11 +2522,16 @@ const selectFormSubmission = (submissionId) => (state) => {
|
|
|
2522
2522
|
};
|
|
2523
2523
|
const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
|
|
2524
2524
|
createSelector(
|
|
2525
|
-
[
|
|
2525
|
+
[
|
|
2526
|
+
selectFormSubmissionsMapping,
|
|
2527
|
+
selectFormRevisionMapping,
|
|
2528
|
+
(_state, formId) => formId
|
|
2529
|
+
],
|
|
2526
2530
|
(submissions, revisionMapping, formId) => {
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2531
|
+
const revisionsOfForm = Object.values(revisionMapping).filter((revision) => revision.form === formId);
|
|
2532
|
+
const revisionIds = new Set(revisionsOfForm.map((revision) => revision.offline_id));
|
|
2533
|
+
return Object.values(submissions).filter((submission) => {
|
|
2534
|
+
return revisionIds.has(submission.form_revision);
|
|
2530
2535
|
});
|
|
2531
2536
|
}
|
|
2532
2537
|
)
|
|
@@ -4090,10 +4095,15 @@ class AssetService extends BaseApiService {
|
|
|
4090
4095
|
if (!assetToBeDeleted)
|
|
4091
4096
|
throw new Error(`No asset with id ${assetId} found in the store`);
|
|
4092
4097
|
const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(store.getState());
|
|
4093
|
-
store.
|
|
4098
|
+
const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(store.getState());
|
|
4099
|
+
this.dispatch(deleteAsset(assetId));
|
|
4094
4100
|
if (attachmentsOfAssets.length > 0) {
|
|
4095
4101
|
const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
|
|
4096
|
-
|
|
4102
|
+
this.dispatch(deleteAssetAttachments(attachmentsOfAssetIds));
|
|
4103
|
+
}
|
|
4104
|
+
if (formSubmissionsOfAssets.length > 0) {
|
|
4105
|
+
const formSubmissionsOfAssetIds = formSubmissionsOfAssets.map(({ offline_id }) => offline_id);
|
|
4106
|
+
this.dispatch(deleteFormSubmissions(formSubmissionsOfAssetIds));
|
|
4097
4107
|
}
|
|
4098
4108
|
return this.enqueueRequest({
|
|
4099
4109
|
description: "Delete asset",
|
|
@@ -4102,8 +4112,9 @@ class AssetService extends BaseApiService {
|
|
|
4102
4112
|
blockers: [assetId],
|
|
4103
4113
|
blocks: []
|
|
4104
4114
|
}).catch((err) => {
|
|
4105
|
-
|
|
4106
|
-
|
|
4115
|
+
this.dispatch(addAsset(assetToBeDeleted));
|
|
4116
|
+
this.dispatch(addAssetAttachments(attachmentsOfAssets));
|
|
4117
|
+
this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
|
|
4107
4118
|
throw err;
|
|
4108
4119
|
});
|
|
4109
4120
|
}
|
|
@@ -4978,12 +4989,15 @@ class IssueService extends BaseApiService {
|
|
|
4978
4989
|
}
|
|
4979
4990
|
const attachmentsOfIssue = selectAttachmentsOfIssue(id)(state);
|
|
4980
4991
|
const updatesOfIssue = selectIssueUpdatesOfIssue(id)(state);
|
|
4992
|
+
const formSubmissionsOfIssue = selectFormSubmissionsOfIssue(id)(state);
|
|
4981
4993
|
this.dispatch(deleteIssue(id));
|
|
4982
4994
|
this.dispatch(addActiveProjectIssuesCount(-1));
|
|
4983
4995
|
if (attachmentsOfIssue.length > 0)
|
|
4984
4996
|
this.dispatch(deleteIssueAttachments(attachmentsOfIssue.map(({ offline_id }) => offline_id)));
|
|
4985
4997
|
if (updatesOfIssue.length > 0)
|
|
4986
4998
|
this.dispatch(deleteIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
|
|
4999
|
+
if (formSubmissionsOfIssue.length > 0)
|
|
5000
|
+
this.dispatch(deleteFormSubmissions(formSubmissionsOfIssue.map(({ offline_id }) => offline_id)));
|
|
4987
5001
|
try {
|
|
4988
5002
|
return await this.enqueueRequest({
|
|
4989
5003
|
description: "Delete issue",
|
|
@@ -4997,6 +5011,7 @@ class IssueService extends BaseApiService {
|
|
|
4997
5011
|
this.dispatch(addIssueAttachments(attachmentsOfIssue));
|
|
4998
5012
|
this.dispatch(addIssueUpdates(updatesOfIssue));
|
|
4999
5013
|
this.dispatch(addActiveProjectIssuesCount(1));
|
|
5014
|
+
this.dispatch(addFormSubmissions(formSubmissionsOfIssue));
|
|
5000
5015
|
throw e;
|
|
5001
5016
|
}
|
|
5002
5017
|
}
|