-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Server Settings: Fix warning in SFTP users #98584
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~14 bytes removed 📉 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
3f400d2
to
ba44a36
Compare
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 🚀
I created an atomic site and confirmed that the warning is gone.
@@ -152,7 +147,7 @@ export const SftpForm = ( { | |||
|
|||
const handleResetPassword = () => { | |||
setPasswordLoading( true ); | |||
dispatch( resetSftpPassword( siteId, username ) ); | |||
dispatch( resetSftpPassword( siteId, username as string ) ); |
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.
As a follow-up, we could improve the logic in this file, since it currently doesn't take into account the possibility that username
is not defined.
I suggest adding some checks and return a fallback UI while they are not defined.
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.
It's all under a username &&
check already, I believe that should be enough:
{ username && ( |
Or are you referring to something else?
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.
The JSX is, but that doesn't mean guarantee TypeScript that username
in the highlighted line is defined. It's at best an implicit typecase, at at worst a possible edge-case runtime error.
Proposed Changes
Simplify the code to retrieve SFTP users. Currently, it creates a new object inside a
useSelector(),
triggering a bunch of additional rerenders. Instead, we can derive the state and avoid those rerenders.Why are these changes being made?
To reduce rerenders and remove this warning:
Testing Instructions
/hosting-config/:site
where:site
is one of your Atomic sites.