-
Notifications
You must be signed in to change notification settings - Fork 106
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: [PE-725] CGN merchant categories list details transition header #6313
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6313 +/- ##
==========================================
- Coverage 48.42% 46.96% -1.47%
==========================================
Files 1488 1803 +315
Lines 31617 36561 +4944
Branches 7669 8705 +1036
==========================================
+ Hits 15311 17170 +1859
- Misses 16238 19334 +3096
+ Partials 68 57 -11
... and 1426 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially, the way it has been implemented solves the issue of the refresh indicator at the startup of the screen. However, by doing so, when a user performs a pull-to-refresh on that list, the refresh indicator doesn’t stay active while waiting for the response. It immediately disappears because the refreshing attribute always receives a false value as input.
To test this use case, you should run the dev-server and the IO app locally. Then, in the dev-server, modify the src/config.ts file
and change the delay property, setting it to something like 2000 (which indicates a 2-second delay for all request to the dev-server). Afterward, go to that screen, and when performing a pull-to-refresh, you’ll notice that the refresh indicator doesn’t stay for 2 seconds but disappears immediately.
Since we want to show the refresh indicator only when the user performs a pull-to-refresh, I’ve outlined below some possible improvements you could apply and consider.
Let me know what do you think.
This is a preview with a delay of 3000ms on every HTTP request:
preview.mov
IOToast.error(I18n.t("global.genericError")); | ||
} | ||
// eslint-disable-next-line functional/immutable-data | ||
isFirstRender.current = false; | ||
setIsFirstRender(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line of code, if we track the isRefreshing
state, isn't needed anymore
@@ -130,7 +129,7 @@ export const CgnMerchantCategoriesListScreen = () => { | |||
renderItem={({ item, index }) => renderCategoryElement(item, index)} | |||
refreshControl={ | |||
<RefreshControl | |||
refreshing={pot.isLoading(potCategories)} | |||
refreshing={isFirstRender && pot.isLoading(potCategories)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refreshing={isFirstRender && pot.isLoading(potCategories)} | |
refreshing={isRefreshing && pot.isLoading(potCategories)} |
|
||
export const CgnMerchantCategoriesListScreen = () => { | ||
const insets = useSafeAreaInsets(); | ||
const isFirstRender = React.useRef<boolean>(true); | ||
const [isFirstRender, setIsFirstRender] = React.useState<boolean>(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead saving the state of the first render, since we want that the "refreshing indicator" will appears only when the user pulls down the list, what do you think about saving the state of isRefreshing
and set it as default value to false
?
const [isFirstRender, setIsFirstRender] = React.useState<boolean>(true); | |
const [isRefreshing, setIsRefreshing] = React.useState<boolean>(false); |
ts/features/bonus/cgn/screens/merchants/CgnMerchantCategoriesListScreen.tsx
Show resolved
Hide resolved
@Hantex9 does this meet your expectations? Screen.Recording.2024-10-22.at.12.25.20.mov |
Yes, this is exactly what I had in mind. The only thing I wanted to point out is that, in the video, it seems like the skeletons have too much horizontal padding and don't match the width of the displayed content. Other than that, everything is perfect in my opinion 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Just a small improvement below, and everything else looks good.
const [isRefreshing, setIsRefreshing] = React.useState(false); | ||
const [isPullRefresh, setIsPullRefresh] = React.useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need two separate states to track this behavior? I believe we could manage with just one state that tracks the pull-to-refresh behavior. When the user opens this screen for the first time, the skeletons should always be shown as long as the pot is in a noneLoading state (i.e., both pot.isNone
and pot.isLoading
). About the the pull-to-refresh, having a separate state makes sense, but for the initial load, a single state should be enough if you check if the pot is none but in loading. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
…6313) ## Short description This pull request includes several changes to the `CgnMerchantCategoriesListScreen.tsx` and `categories.ts` files to improve the handling of the first render state and loading indicators. ## List of changes proposed in this pull request - Update CGN categories store loading state to `noneLoading` - Ensure the `RefreshControl` component does not appear on the first render. ## How to test - Enter into CGN detail screen - Press on _Scopri le opportunità_ - Check the list transition --------- Co-authored-by: Alessandro <[email protected]>
Short description
This pull request includes several changes to the
CgnMerchantCategoriesListScreen.tsx
andcategories.ts
files to improve the handling of the first render state and loading indicators.List of changes proposed in this pull request
noneLoading
RefreshControl
component does not appear on the first render.How to test