Sync: Remove unnecesary ref when initializing Push states - #1980
Conversation
📊 Performance Test ResultsComparing 9b7589b vs trunk site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change |
fredrikekelund
left a comment
There was a problem hiding this comment.
LGTM 👍 I haven't tested, but I feel confident about the code changes.
|
|
||
| const { client } = useAuth(); | ||
| const { pushStatesProgressInfo } = useSyncStatesProgressInfo(); | ||
| const hasInitialized = useRef( false ); |
There was a problem hiding this comment.
At first, I was going to say that I think it's a good idea to make our intention explicit, only to run this effect once (i.e., to preserve the ref). However, after thinking about it, I realized that re-running it whenever client changes actually makes a lot of sense, since it will rerun when the user authenticates with WordPress.com.
There was a problem hiding this comment.
Yes, indeed, I didn't think of that use case, but I have tested it, and it works perfectly. The progress is displayed after authentication 👍
| }; | ||
|
|
||
| void initializePushStates().catch( ( error ) => { | ||
| initializePushStates().catch( ( error ) => { |
Related issues
Proposed Changes
useEffectto run multiple times as it is not necessary anymore after be16976voidoperator as the promise is handled by the.catchTesting Instructions
importendpoint is checked only once for the connected sites initially, and it is not executed when selecting the Sync tab of different sites every time. Please note that if there is an operation in progress, theimportendpoint will be checked periodically.Pre-merge Checklist