Skip to content

Commit 8e2eea1

Browse files
committed
fix: multiple button created
1 parent ac2f972 commit 8e2eea1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

entrypoints/content/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,24 @@ export default defineContentScript({
88
const isRepoPage = () => window.location.pathname.match(/^\/[^/]+\/[^/]+/);
99

1010
// Function to manage button visibility
11+
let isCreatingButton = false; // Flag to prevent concurrent button creation
12+
1113
const manageButton = () => {
1214
const existingButton = document.getElementById('git-ingest-button');
1315

1416
if (isRepoPage()) {
15-
if (!existingButton) {
17+
if (!existingButton && !isCreatingButton) {
18+
isCreatingButton = true;
1619
// Handle async operation without changing function signature
1720
createGitIngestButton()
18-
.then(button => appendGitIngestButton(button))
19-
.catch(console.error);
21+
.then(button => {
22+
appendGitIngestButton(button);
23+
isCreatingButton = false;
24+
})
25+
.catch(error => {
26+
console.error(error);
27+
isCreatingButton = false;
28+
});
2029
}
2130
} else {
2231
existingButton?.remove();

0 commit comments

Comments
 (0)