Skip to content

Commit

Permalink
code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyantong2000 committed Aug 23, 2024
1 parent 1e93f13 commit 1ed36af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
17 changes: 8 additions & 9 deletions src/components/OSGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ const OSGraph: React.FC<OSGraphProps> = ({ shareId, style = {}, OSGraphUrl }) =>
const iframeRef = useRef<HTMLIFrameElement>(null);

useEffect(() => {
// async
if (shareId < 3) {
setTimeout(() => {
if (iframeRef.current) {
iframeRef.current.src = OSGraphUrl;
}
}, shareId * 500); // Each iframe delays 500ms
} else {
const loadIframe = () => {
if (iframeRef.current) {
iframeRef.current.src = OSGraphUrl;
}
};
// async
if (shareId < 3) {
setTimeout(loadIframe, shareId * 500); // Each iframe delays 500ms
} else {
loadIframe();
}
}, [iframeRef, OSGraphUrl, shareId]);
}, [OSGraphUrl, shareId]);

return (
<div className="hypertrons-crx-border">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const OSGraphStyle = {
width: '100%',
height: '400px',
border: 'none',
marginTop: '70px',
};
const logoStyle = {
cssFloat: 'right',
Expand Down
2 changes: 0 additions & 2 deletions src/pages/ContentScripts/features/repo-networks/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const OSGraphStyle = {
width: '100%',
height: '400px',
border: 'none',
objectFit: 'cover' as 'cover',
marginTop: '70px',
};

const logoStyle = {
Expand Down

0 comments on commit 1ed36af

Please sign in to comment.