Skip to content

Commit

Permalink
fix(exports): fix elements to delete not appearing in exports (#1482)
Browse files Browse the repository at this point in the history
  • Loading branch information
cberthou committed Oct 19, 2022
1 parent 929c617 commit d0be53f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/renderer/utils/array-export/array-export.ts
@@ -1,6 +1,6 @@
import type { HashesMap } from "@common/utils/hashes-types";
import type { TFunction } from "i18next";
import _, { flatten } from "lodash";
import _, { flatten, identity } from "lodash";
import { compose, cond, defaults, isObject, prop, stubTrue } from "lodash/fp";
import { concat, from, interval, Observable } from "rxjs";
import { map, take, tap, toArray } from "rxjs/operators";
Expand Down Expand Up @@ -116,13 +116,21 @@ const removeDuplicateCells = (
),
});

const shouldRemoveToDelete = (params: CsvExporterData & WithRowConfig) =>
params.elementsToDelete.length === 0;

const removeToDeleteCells = (
params: CsvExporterData & WithRowConfig
): CsvExporterData & WithRowConfig => ({
...params,
rowConfig: params.rowConfig.filter(({ id }) => id !== "toDelete"),
});

const maybeRemoveToDeleteCells = cond([
[shouldRemoveToDelete, removeToDeleteCells],
[stubTrue, identity],
]);

const setDefaultHashesValue = <T>(params: T) =>
defaults({ hashes: {} }, params);

Expand Down Expand Up @@ -160,7 +168,7 @@ export const exportToCsv: (input: CsvExporterData) => Observable<string[][]> =
generateHeaderRow,
prepareIdsToDelete,
setDefaultHashesValue,
removeToDeleteCells,
maybeRemoveToDeleteCells,
maybeRemoveDuplicates,
addRowConfig
);
Expand Down

0 comments on commit d0be53f

Please sign in to comment.