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 duplicate events on events page #3053

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

agustif
Copy link
Contributor

@agustif agustif commented Dec 16, 2021

Description

  • Make sure duplicate events are not possible on events list component in events page.
  • Sorry team, this one is a hard to reproduce bug from metacolony, if anyone knows how to test it direclty with metacolony prod data that'd be nice..
    Otherwise, we can introduce artificially duplicate streamedEvents at the new Set:
  const {
    data,
    loading: subgraphEventsLoading,
    error,
  } = useSubgraphEventsSubscription({
    variables: {
      skip: dataPage === 1 ? 0 : ITEMS_PER_PAGE * dataPage,
      first: ITEMS_PER_PAGE,
      colonyAddress: colonyAddress.toLowerCase(),
      sortDirection: 'desc',
    },
    onSubscriptionData: ({ subscriptionData: { data: newSubscriptionData } }) =>
      setStreamedEvents([
        ...new Set([
          ...streamedEvents,
          ...streamedEvents,
          ...(newSubscriptionData?.events || []),
        ]),
      ]),
  });

and see if Set catches and removes 'em.

Changes 🏗

  • Wrap current array for events into set, so it filters them by ID.

Minor cosmetic changes ⚰️

  • setstreamedEvents uppercased to -> setStreamedEvents

TODO

Resolves #3045

@agustif agustif self-assigned this Dec 16, 2021
@agustif agustif force-pushed the fix/3045-duplicate-events branch from 49296f9 to be3371b Compare December 16, 2021 16:05
@agustif agustif requested a review from a team December 16, 2021 16:09
@agustif agustif added the bug label Dec 16, 2021
@agustif agustif marked this pull request as ready for review December 16, 2021 16:10
@agustif agustif force-pushed the fix/3045-duplicate-events branch from be3371b to a498ecf Compare December 17, 2021 21:45
Copy link
Contributor

@ArmandoGraterol ArmandoGraterol left a comment

Choose a reason for hiding this comment

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

Well, with the example you provided it seems to be working, and in theory, it should work with prod's data, so I guess it's good to go!

@agustif
Copy link
Contributor Author

agustif commented Dec 17, 2021

Well, with the example you provided it seems to be working, and in theory, it should work with prod's data, so I guess it's good to go!

Thanks for the input @ArmandoGraterol . Do you think I should look in adding this in Actions Page too? Doesn't think the a bug has showed there yet, but might be good for -guard railing- in the future? Will look into it

@ArmandoGraterol
Copy link
Contributor

Well, with the example you provided it seems to be working, and in theory, it should work with prod's data, so I guess it's good to go!

Thanks for the input @ArmandoGraterol . Do you think I should look in adding this in Actions Page too? Doesn't think the a bug has showed there yet, but might be good for -guard railing- in the future? Will look into it

I haven't seen that happen in the action list, so I don't think it's necessary right now but if it doesn't hurt performance then you can try adding it there too

Copy link
Contributor

@chinins chinins left a comment

Choose a reason for hiding this comment

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

Seems to be working. I agree with Armando that we shouldn't change anything in the ActionsList because the logic there is a bit different.

@agustif agustif force-pushed the fix/3045-duplicate-events branch from a498ecf to 4fe6122 Compare December 20, 2021 09:17
@ArmandoGraterol ArmandoGraterol force-pushed the fix/3045-duplicate-events branch from 4fe6122 to 9035982 Compare January 27, 2022 15:32
@ArmandoGraterol ArmandoGraterol merged commit b2c1c1c into master Jan 27, 2022
@ArmandoGraterol ArmandoGraterol deleted the fix/3045-duplicate-events branch January 27, 2022 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate events appearing on Events page.
3 participants