Skip to content

Commit f34790d

Browse files
committed
Add the interval even if the button doesn't render
1 parent 06082c9 commit f34790d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/app/src/watermark-button.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ const createIframe = () => {
6666

6767
const iframeId = `sb__open-sandbox${Math.floor(Math.random() * 100)}`;
6868
iframe.setAttribute('id', iframeId);
69+
70+
clearInterval(interval);
71+
interval = setInterval(() => {
72+
// Check every second whether the button is still there
73+
if (!document.getElementById(iframeId)) {
74+
createIframe();
75+
}
76+
}, 1000);
77+
6978
const link = document.createElement('a');
7079
setIframeStyle(iframe);
7180

@@ -94,14 +103,6 @@ const createIframe = () => {
94103
childList: true,
95104
subtree: true,
96105
});
97-
98-
clearInterval(interval);
99-
interval = setInterval(() => {
100-
// Check every second whether the button is still there
101-
if (!document.getElementById(iframeId)) {
102-
createIframe();
103-
}
104-
}, 1000);
105106
};
106107

107108
document.body.appendChild(iframe);

0 commit comments

Comments
 (0)