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: [IOCOM-1091] Fix for duplicate message in messages list #5509

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

Vangaorth
Copy link
Contributor

@Vangaorth Vangaorth commented Feb 13, 2024

Short description

This PR fixes a condition where a new message could appear twice in the messages list.

List of changes proposed in this pull request

In the Message List component:

  • Proper use of focus effect, using React's useFocusEffect with proper dependencies
  • Loading of previous messages page (with focus effect) does not trigger anymore when the component is already refreshing all messages.

Latter is what was causing the bug: two subsequent asynchronous requests (one for all messages and one for just the new one - the previous page) where the first retrieved all messages while the second just the new ones, using the current-but-soon-to-be-outdated starting index (minimum_id).
So, the reload-all request ends, filling the redux state with all new and old messages. If the previous-page request ends after that, its data has some duplicates in it (the new messages - since its starting minimum_id was the old one, not the current one received from the last reload-all) but the reducer puts them in front of the previously receveid ones from the reload-all, duplicating some of them.

How to test

You can use the io-dev-api-server code on this PR to create a new message.

Do the following in less than 60 seconds (the refresh time): select a message, create a new one (POST message endpoint) and go back to the message list. Now wait for the 60 seconds to expire and use the pull-down-to-refresh. On the main branch, two duplicated messages should appear on top of the list. On this branch, there is no duplicate.

@pagopa-github-bot pagopa-github-bot changed the title [IOCOM-1091] Fix for duplicate message in messages list fix: [IOCOM-1091] Fix for duplicate message in messages list Feb 13, 2024
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Feb 13, 2024

Affected stories

Generated by 🚫 dangerJS against abb306e

Copy link

codecov bot commented Feb 13, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (1e87608) 47.98% compared to head (abb306e) 47.93%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5509      +/-   ##
==========================================
- Coverage   47.98%   47.93%   -0.05%     
==========================================
  Files        1402     1402              
  Lines       30360    30366       +6     
  Branches     7390     7391       +1     
==========================================
- Hits        14569    14557      -12     
- Misses      15733    15751      +18     
  Partials       58       58              
Files Coverage Δ
...features/messages/components/MessageList/index.tsx 60.57% <81.25%> (+0.37%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e87608...abb306e. Read the comment docs.

@Vangaorth Vangaorth marked this pull request as ready for review February 13, 2024 16:10
@Vangaorth Vangaorth requested a review from a team as a code owner February 13, 2024 16:10
@Vangaorth Vangaorth merged commit cb14f8a into master Feb 14, 2024
8 checks passed
@Vangaorth Vangaorth deleted the IOCOM-1091 branch February 14, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants