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 1 commit
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
20 changes: 3 additions & 17 deletions packages/landing/src/components/daterange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,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 | undefined {
return this.state.after?.slice(0, 4);
}
Expand All @@ -23,19 +20,6 @@ export class DateRange extends Component {
return this.state.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 @@ -45,7 +29,9 @@ export class DateRange extends Component {
this.setState({ before: `${event.target.value}-12-31T23:59:59.999Z` });
break;
}
this.scheduleUpdateConfig();
Config.map.dateRange.dateAfter = this.state.dateAfter;
ajacombs marked this conversation as resolved.
Show resolved Hide resolved
ajacombs marked this conversation as resolved.
Show resolved Hide resolved
Config.map.dateRange.dateBefore = this.state.dateBefore;
Config.map.emit('dateRange', this.state);
};

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 @@ -91,7 +91,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 === undefined) Config.map.visibleLayers = newLayers;
blacha marked this conversation as resolved.
Show resolved Hide resolved
if (newLayers !== Config.map.visibleLayers) {
Config.map.visibleLayers = newLayers;
const newStyleId =
Expand Down