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 fetchEvents #628

Merged
merged 3 commits into from
Dec 5, 2022
Merged

fix fetchEvents #628

merged 3 commits into from
Dec 5, 2022

Conversation

Trivo25
Copy link
Member

@Trivo25 Trivo25 commented Dec 4, 2022

closes #627

@@ -1001,11 +1001,11 @@ super.init();
// if there are multiple events we have to use the index event[0] to find the exact event type
let type = sortedEventTypes[event[0]];
// all other elements of the array are values used to construct the original object, we can drop the first value since its just an index
event.shift();
let eventProps = event.slice(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't this equivalent? 😮
I'd love to understand what the issue here was and how this fixes it

Copy link
Member Author

Choose a reason for hiding this comment

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

The bug appeared when we called fetchEvents more than once, because shift manipulates the original array, slice doesn't.
So every time we called fetchEvents, we would drop an element of the original array until the array would be empty

@Trivo25 Trivo25 merged commit a99df5c into main Dec 5, 2022
@Trivo25 Trivo25 deleted the fix-events branch December 5, 2022 12:46
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.

SnarkyJS error in fetchEvents when multiple event types exist
2 participants