Skip to content

Commit

Permalink
Move useEffect logic to a method for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
medied committed Apr 3, 2024
1 parent e24f898 commit da477e3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ const Edit = ( {
}
};

const waitOneSecThenDisplayCustomTooltip = () => {
setTimeout( () => {
setDisplayCustomTooltip( true );
// eslint-disable-next-line no-undef
localStorage.setItem( 'WikipediaPreviewWordpressPlugin-CustomTooltipDisplayedCount', customTooltipDisplayedCount + 1 );
}, 1000 );
};

useEffect( () => {
if ( Object.keys( activeAttributes ).length ) {
stopAddingPreview();
Expand All @@ -202,11 +210,7 @@ const Edit = ( {
useEffect( () => {
if ( customTooltipDisplayedCount < customTooltipDisplayedLimit ) {
// Wait 1 second and then display tooltip
setTimeout( () => {
setDisplayCustomTooltip( true );
// eslint-disable-next-line no-undef
localStorage.setItem( 'WikipediaPreviewWordpressPlugin-CustomTooltipDisplayedCount', customTooltipDisplayedCount + 1 );
}, 1000 );
waitOneSecThenDisplayCustomTooltip();
}
} );

Expand Down

0 comments on commit da477e3

Please sign in to comment.