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 #150: dateRangeChange incorrectly called #155

Merged
merged 1 commit into from
Aug 9, 2022

Conversation

tjuranek
Copy link
Contributor

Overview

Fixes #150.

When in live mode, the viewportHandler tick cycle was passing the updated viewport back to the rendered chart. The logic was set to emit the dateRangeChange event any time the viewport changed. When in live mode this isn't the desired behavior so a flag was added to be able to check for that and block the event from being emitted.

Tests

[Include a link to the passing GitHub action running the test suite here.]

Legal

This project is available under the Apache 2.0 License.

@tjuranek tjuranek requested review from diehbria and boweihan July 29, 2022 17:06
@jmbuss
Copy link
Contributor

jmbuss commented Aug 5, 2022

Don't forget to squash all the commits into 1! :D

block event emission when viewport changes due to a live mode update

fix linting issues

add rest property types to updateViewPort

fix #150 dateRangeChange called in live mode
@tjuranek tjuranek force-pushed the bug-fix-150-dateRangeChange branch from b1e47a3 to 797b043 Compare August 9, 2022 16:04
@tjuranek tjuranek requested review from boweihan and jmbuss August 9, 2022 16:05
@tjuranek tjuranek merged commit b4adbe5 into main Aug 9, 2022
@tjuranek tjuranek deleted the bug-fix-150-dateRangeChange branch August 9, 2022 16:22
manager.updateViewPort({ start: newStart, end: newEnd, duration });

// Have manager update its own viewport, preventing 'dateRangeChange' events when in live mode
const isInLiveMode = Boolean(duration);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just say duration != duration (a common pattern in this code base) rather than relying on the fact that Boolean(undefined) === 0

Another thought: what does duration: 0 imply? Would it possibly make sense to be in live mode, but only for a single instance in time? With this logic, it would detect as not being in live mode

jest.advanceTimersByTime(secondsElapsed * SECOND_IN_MS);
expect(manager.updateViewPort).toBeCalledWith(
expect.objectContaining({
shouldBlockDateRangeChangedEvent: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

what about the situation where it shouldn't be blocked?

diehbria pushed a commit that referenced this pull request Sep 29, 2022
add flag for blocking dateRangeChanged event when in live mode

block event emission when viewport changes due to a live mode update

fix linting issues

add rest property types to updateViewPort

Co-authored-by: Thomas Juranek <thjurane@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dateRangeChange incorrectly called when viewport is duration based
4 participants