Skip to content

Commit

Permalink
fix default value is array vs single value
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurmarakana89 committed Feb 20, 2024
1 parent e2125bf commit 9cc6ff0
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ export class TimeSliderEventProcessor extends AbstractEventProcessor {
const name = getLocalizedValue(api.maps[mapId].layer.geoviewLayers[layerPath.split('/')[0]].geoviewLayerName, mapId) || layerPath;
const temporalDimensionInfo = api.maps[mapId].layer.geoviewLayer(layerPath).getTemporalDimension();
const { range } = temporalDimensionInfo.range;
const defaultValue = temporalDimensionInfo.default;
const defaultValueIsArray = Array.isArray(temporalDimensionInfo.default);
const defaultValue = defaultValueIsArray ? temporalDimensionInfo.default[0] : temporalDimensionInfo.default;
const minAndMax: number[] = [new Date(range[0]).getTime(), new Date(range[range.length - 1]).getTime()];
const { field, singleHandle } = temporalDimensionInfo;

Expand All @@ -122,7 +123,12 @@ export class TimeSliderEventProcessor extends AbstractEventProcessor {
const fieldIndex = localizedOutFields ? localizedOutFields.indexOf(field) : -1;
if (fieldIndex !== -1 && localizedAliasFields?.length === localizedOutFields?.length) fieldAlias = localizedAliasFields![fieldIndex];

const values = singleHandle ? [new Date(temporalDimensionInfo.default).getTime()] : [...minAndMax];
// eslint-disable-next-line no-nested-ternary
const values = singleHandle
? [new Date(temporalDimensionInfo.default).getTime()]
: defaultValueIsArray
? [new Date(temporalDimensionInfo.default[0]).getTime(), new Date(temporalDimensionInfo.default[1]).getTime()]
: [...minAndMax];

const sliderData: TimeSliderLayerSet = {
[layerPath]: {
Expand Down

0 comments on commit 9cc6ff0

Please sign in to comment.