@overmap-ai/core 1.0.61 → 1.0.62-store-clear-fixes.1

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.
@@ -2323,10 +2323,17 @@ var __publicField = (obj, key, value) => {
2323
2323
  return ret;
2324
2324
  };
2325
2325
  const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
2326
- toolkit.createSelector([selectFormRevisions, (_state, formId) => formId], (revisions, formId) => {
2327
- const sortedRevisions = revisions.filter((revision) => revision.form === formId).sort(formRevisionSortFn).reverse();
2328
- return sortedRevisions.length > 0 ? sortedRevisions[0] : void 0;
2329
- })
2326
+ toolkit.createSelector(
2327
+ [selectFormRevisionMapping, (_state, formId) => formId],
2328
+ (revisions, formId) => {
2329
+ const revisionsOfForm = Object.values(revisions).filter((revision) => revision.form === formId);
2330
+ if (revisionsOfForm.length === 0)
2331
+ return void 0;
2332
+ const sortedRevisions = revisionsOfForm.sort(formRevisionSortFn);
2333
+ const latestRevision = sortedRevisions[revisionsOfForm.length - 1];
2334
+ return revisions[latestRevision.offline_id];
2335
+ }
2336
+ )
2330
2337
  );
2331
2338
  const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
2332
2339
  toolkit.createSelector(
@@ -2503,11 +2510,16 @@ var __publicField = (obj, key, value) => {
2503
2510
  };
2504
2511
  const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2505
2512
  toolkit.createSelector(
2506
- [selectFormSubmissions, selectFormRevisionMapping, (_state, formId) => formId],
2513
+ [
2514
+ selectFormSubmissionsMapping,
2515
+ selectFormRevisionMapping,
2516
+ (_state, formId) => formId
2517
+ ],
2507
2518
  (submissions, revisionMapping, formId) => {
2508
- return submissions.filter((submission) => {
2509
- const revision = revisionMapping[submission.form_revision];
2510
- return (revision == null ? void 0 : revision.form) === formId;
2519
+ const revisionsOfForm = Object.values(revisionMapping).filter((revision) => revision.form === formId);
2520
+ const revisionIds = new Set(revisionsOfForm.map((revision) => revision.offline_id));
2521
+ return Object.values(submissions).filter((submission) => {
2522
+ return revisionIds.has(submission.form_revision);
2511
2523
  });
2512
2524
  }
2513
2525
  )