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

chore(IT Wallet): [SIW-1878] Loader before SPID Login Webview #6493

Merged
merged 7 commits into from
Dec 5, 2024

Conversation

RiccardoMolinari95
Copy link
Collaborator

@RiccardoMolinari95 RiccardoMolinari95 commented Dec 4, 2024

Short description

This PR fix the loader until the WebView has finished loading in ItwSpidIdpLoginScreen. Previously, there was a brief moment where the component appeared empty before the WebView was ready.

List of changes proposed in this pull request

  • Added the onLoadEnd property to the WebView to handle the end of the loading process

How to test

Activate "Documenti su IO" using SPID as authentication method

Warning

Tested only on Android

Screen.Recording.2024-12-04.at.14.48.44.mov

@RiccardoMolinari95 RiccardoMolinari95 self-assigned this Dec 4, 2024
@pagopa-github-bot pagopa-github-bot changed the title [SIW-1878] Loader before SPID Login Webview chore(IT Wallet): [SIW-1878] Loader before SPID Login Webview Dec 4, 2024
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Dec 4, 2024

Affected stories

  • ⚙️ SIW-1878: [io-app] Inserire indicatore di loading durante la preparazione della webiew di identificazione via SPID

Generated by 🚫 dangerJS against 02d6b5d

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 48.41%. Comparing base (4f204b4) to head (02d6b5d).
Report is 840 commits behind head on master.

Files with missing lines Patch % Lines
...ntification/screens/spid/ItwSpidIdpLoginScreen.tsx 0.00% 6 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6493      +/-   ##
==========================================
- Coverage   48.42%   48.41%   -0.02%     
==========================================
  Files        1488     1577      +89     
  Lines       31617    32184     +567     
  Branches     7669     7331     -338     
==========================================
+ Hits        15311    15582     +271     
- Misses      16238    16549     +311     
+ Partials       68       53      -15     
Files with missing lines Coverage Δ
...ntification/screens/spid/ItwSpidIdpLoginScreen.tsx 8.33% <0.00%> (ø)

... and 1714 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 f5cf7ce...02d6b5d. Read the comment docs.

Comment on lines 132 to 136
return (
<LoadingSpinnerOverlay isLoading={isLoading}>
<View style={styles.webViewWrapper}>{content}</View>
</LoadingSpinnerOverlay>
);
Copy link
Contributor

@mastro993 mastro993 Dec 4, 2024

Choose a reason for hiding this comment

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

isMachineLoading is redundant, but we can use it in the isLoading prop of the LoadingSpinnerOverlay component. What do you think?

Suggested change
return (
<LoadingSpinnerOverlay isLoading={isLoading}>
<View style={styles.webViewWrapper}>{content}</View>
</LoadingSpinnerOverlay>
);
return (
<LoadingSpinnerOverlay isLoading={isLoading || isMachineLoading}>
<View style={styles.webViewWrapper}>{content}</View>
</LoadingSpinnerOverlay>
);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @mastro993, I have conducted some tests, including the suggestion to use isMachineLoading directly in the isLoading property of the LoadingSpinnerOverlay component. However, I found that if isMachineLoading is set to true for testing, the loader remains visible and the WebView appears underneath it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you try to set loadingOpacity to 1.0? This will make the LoadingSpinnerOverlay completely cover the webview until it is ready.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, now I'll try. Thanks for the suggestion

Comment on lines 101 to 121
!isMachineLoading && O.isSome(spidAuthUrl) ? (
<WebView
cacheEnabled={false}
androidCameraAccessDisabled
androidMicrophoneAccessDisabled
javaScriptEnabled
textZoom={100}
originWhitelist={originSchemasWhiteList}
source={{ uri: spidAuthUrl.value }}
onError={onError}
onHttpError={onError}
onNavigationStateChange={handleNavigationStateChange}
onShouldStartLoadWithRequest={handleShouldStartLoading}
allowsInlineMediaPlayback
mediaPlaybackRequiresUserAction
userAgent={defaultUserAgent}
onLoadEnd={onLoadEnd}
/>
) : (
<></>
),
Copy link
Contributor

Choose a reason for hiding this comment

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

If spidAuthUrl is not ready or present, it likely indicates that the machine is still loading. This makes isMachineLoading redundant in this context. I suggest we keep the original code and add a fallback to null to prevent rendering multiple spinners. What do you think?

Suggested change
!isMachineLoading && O.isSome(spidAuthUrl) ? (
<WebView
cacheEnabled={false}
androidCameraAccessDisabled
androidMicrophoneAccessDisabled
javaScriptEnabled
textZoom={100}
originWhitelist={originSchemasWhiteList}
source={{ uri: spidAuthUrl.value }}
onError={onError}
onHttpError={onError}
onNavigationStateChange={handleNavigationStateChange}
onShouldStartLoadWithRequest={handleShouldStartLoading}
allowsInlineMediaPlayback
mediaPlaybackRequiresUserAction
userAgent={defaultUserAgent}
onLoadEnd={onLoadEnd}
/>
) : (
<></>
),
O.fold(
() => null,
(url: string) => (
<WebView
key={"spid_webview"}
cacheEnabled={false}
androidCameraAccessDisabled
androidMicrophoneAccessDisabled
javaScriptEnabled
textZoom={100}
originWhitelist={originSchemasWhiteList}
source={{ uri: url }}
onError={onError}
onHttpError={onError}
onNavigationStateChange={handleNavigationStateChange}
onShouldStartLoadWithRequest={handleShouldStartLoading}
allowsInlineMediaPlayback
mediaPlaybackRequiresUserAction
userAgent={defaultUserAgent}
onLoadEnd={onLoadEnd}
/>
)
)(spidAuthUrl),

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that having isMachineLoading set to true and having the auth URL at the same time is unlikely, as one depends on the other. The machine is loading first, and then it receives the auth URL. Therefore, isMachineLoading is redundant in this context.
I'm agree with you

@@ -41,6 +37,11 @@ const ItwSpidIdpLoginScreen = () => {
const spidAuthUrl =
ItwEidIssuanceMachineContext.useSelector(selectAuthUrlOption);
const machineRef = ItwEidIssuanceMachineContext.useActorRef();
const [isLoading, setIsLoading] = useState(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Adds more context. What do you think?

Suggested change
const [isLoading, setIsLoading] = useState(true);
const [isWebViewLoading, setWebViewLoading] = useState(true);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it's okay.

Copy link
Contributor

@mastro993 mastro993 left a comment

Choose a reason for hiding this comment

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

LGTM

@mastro993 mastro993 merged commit 4e19eaa into master Dec 5, 2024
12 checks passed
@mastro993 mastro993 deleted the SIW-1878-spid-login-webview-loader branch December 5, 2024 14:22
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