-
Notifications
You must be signed in to change notification settings - Fork 4
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
[IOCOM-1091] Add a message endpoint to create a new message #349
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #349 +/- ##
==========================================
- Coverage 70.59% 70.44% -0.16%
==========================================
Files 141 141
Lines 4635 4652 +17
Branches 544 544
==========================================
+ Hits 3272 3277 +5
- Misses 1362 1374 +12
Partials 1 1
Continue to review full report in Codecov by Sentry.
|
## 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](pagopa/io-dev-api-server#349) 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. Co-authored-by: Alessandro Dell'Oste <[email protected]>
It might be useful to add this api call in the |
Agreed, added |
Short description
This PR adds a new endpoint to create a new message while the dev-server is running.
List of changes proposed in this pull request
MessagesService
MessagesDatabase
MessagesRouter
How to test
Call the
POST message
endpoint and check that the message is correctly created and retrieved using themessages
endpoint