Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/iris-grid/src/IrisGridUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ describe('pendingDataMap hydration/dehydration', () => {
1,
{
data: new Map([
[3, 'Foo'],
[4, 'Bar'],
[3, { value: 'Foo' }],
[4, { value: 'Bar' }],
]),
},
],
[
10,
{
data: new Map([[7, 'Baz']]),
data: new Map([[7, { value: 'Baz' }]]),
},
],
]);
Expand Down Expand Up @@ -267,10 +267,16 @@ describe('pendingDataMap hydration/dehydration', () => {
);
expect(hydratedMap.size).toBe(2);
expect(hydratedMap.get(1)?.data.size).toBe(2);
expect(hydratedMap.get(1)?.data.get(3)).toEqual('Foo');
expect(hydratedMap.get(1)?.data.get(4)).toEqual('Bar');
expect(hydratedMap.get(1)?.data.get(3)).toEqual(
expect.objectContaining({ value: 'Foo' })
);
expect(hydratedMap.get(1)?.data.get(4)).toEqual(
expect.objectContaining({ value: 'Bar' })
);
expect(hydratedMap.get(10)?.data.size).toBe(1);
expect(hydratedMap.get(10)?.data.get(7)).toEqual('Baz');
expect(hydratedMap.get(10)?.data.get(7)).toEqual(
expect.objectContaining({ value: 'Baz' })
);
});
});

Expand Down
29 changes: 9 additions & 20 deletions packages/iris-grid/src/IrisGridUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export interface DehydratedIrisGridState {
selectDistinctColumns: readonly ColumnName[];
selectedSearchColumns: readonly ColumnName[];
invertSearchColumns: boolean;
pendingDataMap: DehydratedPendingDataMap<string | CellData | null>;
pendingDataMap: DehydratedPendingDataMap<unknown>;
frozenColumns: readonly ColumnName[];
columnHeaderGroups?: readonly DhType.ColumnGroup[];
partitionConfig?: DehydratedPartitionConfig;
Expand Down Expand Up @@ -1495,36 +1495,28 @@ class IrisGridUtils {

dehydratePendingDataMap(
columns: readonly DhType.Column[],
pendingDataMap: ReadonlyMap<
ModelIndex,
{
data: Map<ModelIndex | ColumnName, CellData | string>;
}
>
): DehydratedPendingDataMap<CellData | string | null> {
pendingDataMap: PendingDataMap
): DehydratedPendingDataMap<unknown> {
return [...pendingDataMap].map(([rowIndex, { data }]) => [
rowIndex,
{
data: [...data]
.filter(([c]) => typeof c === 'number')
.map(([c, value]) => [
.map(([c, cellData]) => [
columns[c as number].name,
this.dehydrateValue(value, columns[c as number].type),
this.dehydrateValue(cellData.value, columns[c as number].type),
]),
},
]);
}

hydratePendingDataMap(
columns: readonly DhType.Column[],
pendingDataMap: DehydratedPendingDataMap<CellData | string | null>
pendingDataMap: DehydratedPendingDataMap<unknown>
): Map<
number,
{
data: Map<
ModelIndex | null,
string | CellData | DhType.LongWrapper | null
>;
data: Map<ModelIndex | null, CellData>;
}
> {
const columnMap = new Map<ColumnName, number>();
Expand All @@ -1540,10 +1532,7 @@ class IrisGridUtils {

return new Map(
pendingDataMap.map(
([rowIndex, { data }]: [
number,
{ data: [string, CellData | string | null][] },
]) => [
([rowIndex, { data }]: [number, { data: [string, unknown][] }]) => [
rowIndex,
{
data: new Map(
Expand All @@ -1552,7 +1541,7 @@ class IrisGridUtils {
assertNotNull(index);
return [
getColumnIndex(columnName) ?? null,
this.hydrateValue(value, columns[index].type),
{ value: this.hydrateValue(value, columns[index].type) },
];
})
),
Expand Down
Loading