@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.
@@ -2335,10 +2335,17 @@ const _selectLatestFormRevision = (formRevisions, formId) => {
2335
2335
  return ret;
2336
2336
  };
2337
2337
  const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
2338
- createSelector([selectFormRevisions, (_state, formId) => formId], (revisions, formId) => {
2339
- const sortedRevisions = revisions.filter((revision) => revision.form === formId).sort(formRevisionSortFn).reverse();
2340
- return sortedRevisions.length > 0 ? sortedRevisions[0] : void 0;
2341
- })
2338
+ createSelector(
2339
+ [selectFormRevisionMapping, (_state, formId) => formId],
2340
+ (revisions, formId) => {
2341
+ const revisionsOfForm = Object.values(revisions).filter((revision) => revision.form === formId);
2342
+ if (revisionsOfForm.length === 0)
2343
+ return void 0;
2344
+ const sortedRevisions = revisionsOfForm.sort(formRevisionSortFn);
2345
+ const latestRevision = sortedRevisions[revisionsOfForm.length - 1];
2346
+ return revisions[latestRevision.offline_id];
2347
+ }
2348
+ )
2342
2349
  );
2343
2350
  const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
2344
2351
  createSelector(
@@ -2515,11 +2522,16 @@ const selectFormSubmission = (submissionId) => (state) => {
2515
2522
  };
2516
2523
  const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2517
2524
  createSelector(
2518
- [selectFormSubmissions, selectFormRevisionMapping, (_state, formId) => formId],
2525
+ [
2526
+ selectFormSubmissionsMapping,
2527
+ selectFormRevisionMapping,
2528
+ (_state, formId) => formId
2529
+ ],
2519
2530
  (submissions, revisionMapping, formId) => {
2520
- return submissions.filter((submission) => {
2521
- const revision = revisionMapping[submission.form_revision];
2522
- return (revision == null ? void 0 : revision.form) === formId;
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);
2523
2535
  });
2524
2536
  }
2525
2537
  )