Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure layer loads when dateBefore set early, then moved back late #2701

Merged
merged 6 commits into from
Mar 21, 2023
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
17 changes: 1 addition & 16 deletions packages/landing/src/components/daterange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export interface DateRangeState {

export class DateRange extends Component {
state: DateRangeState = { after: MinDate, before: MaxDate };
private _scheduled: number | NodeJS.Timeout | undefined;
private _raf = 0;

get yearAfter(): string {
return Config.map.filter.date.after == null ? MinDate.slice(0, 4) : Config.map.filter.date.after.slice(0, 4);
Expand All @@ -22,19 +20,6 @@ export class DateRange extends Component {
return Config.map.filter.date.before == null ? MaxDate.slice(0, 4) : Config.map.filter.date.before.slice(0, 4);
}

private scheduleUpdateConfig(): void {
if (this._scheduled != null || this._raf !== 0) return;
this._scheduled = setTimeout(() => {
this._scheduled = undefined;
this._raf = requestAnimationFrame(this.updateConfig);
}, 200);
}

updateConfig = (): void => {
this._raf = 0;
Config.map.setFilterDateRange(this.state.after, this.state.before);
};

handleChange = (event: React.ChangeEvent<HTMLInputElement>, id: 'before' | 'after'): void => {
switch (id) {
case 'after':
Expand All @@ -44,7 +29,7 @@ export class DateRange extends Component {
this.setState({ before: `${event.target.value}-12-31T23:59:59.999Z` });
break;
}
this.scheduleUpdateConfig();
Config.map.setFilterDateRange(this.state.after, this.state.before);
};

render(): ReactNode {
Expand Down
2 changes: 1 addition & 1 deletion packages/landing/src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class Basemaps extends Component<unknown, { isLayerSwitcherEnabled: boole
};

updateVisibleLayers = (newLayers: string): void => {
if (!Config.map.visibleLayers) Config.map.visibleLayers = newLayers;
if (Config.map.visibleLayers == null) Config.map.visibleLayers = newLayers;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think visibleLayers is defined as string and not initialised. Might be better to defined as string|null. Then you can do this check for initialising here.

if (newLayers !== Config.map.visibleLayers) {
Config.map.visibleLayers = newLayers;
const newStyleId =
Expand Down