diff --git a/CHANGELOG.md b/CHANGELOG.md index bbad8c92..9ae0ea03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ > All notable changes to this project will be documented in this file +## [1.12.1-beta.1](https://github.com/open-sauced/ai/compare/v1.12.0...v1.12.1-beta.1) (2023-08-10) + + +### 🐛 Bug Fixes + +* Multiple button injections ([#244](https://github.com/open-sauced/ai/issues/244)) ([0e06d3e](https://github.com/open-sauced/ai/commit/0e06d3edd5639f469dc8504077487cfd88eb3506)) + ## [1.12.0](https://github.com/open-sauced/ai/compare/v1.11.1...v1.12.0) (2023-07-31) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index cf467932..df601aa9 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,12 +1,12 @@ { "name": "opensauced-browser-extension", - "version": "1.12.0", + "version": "1.12.1-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "opensauced-browser-extension", - "version": "1.12.0", + "version": "1.12.1-beta.1", "dependencies": { "date-fns": "^2.30.0", "gpt-tokenizer": "^1.0.5", @@ -1285,9 +1285,9 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz", - "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -1430,9 +1430,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz", - "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -1511,9 +1511,9 @@ } }, "node_modules/@typescript-eslint/utils/node_modules/semver": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz", - "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -2372,9 +2372,9 @@ } }, "node_modules/concordance/node_modules/semver": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", - "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -6195,11 +6195,10 @@ } }, "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, - "license": "ISC", "bin": { "semver": "bin/semver.js" } @@ -7431,9 +7430,9 @@ } }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" diff --git a/package.json b/package.json index eccbf868..c1f47d8b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "opensauced-browser-extension", "private": true, - "version": "1.12.0", + "version": "1.12.1-beta.1", "files": [ "dist" ], diff --git a/src/hooks/useGetGitHubPageInfo.ts b/src/hooks/useGetGitHubPageInfo.ts index 296e64fc..16ed69ec 100644 --- a/src/hooks/useGetGitHubPageInfo.ts +++ b/src/hooks/useGetGitHubPageInfo.ts @@ -1,5 +1,6 @@ import { useEffect, useState } from "react"; import { isGithubPullRequestPage, isGithubRepoPage } from "../utils/urlMatchers"; +import { isPublicRepository } from "../utils/fetchGithubAPIData"; interface GitHubPageInfo { pageUrl: string; @@ -11,13 +12,13 @@ export const usGetGitHubPageInfo = () => { const [GithubPage, setGithubPage] = useState({ pageUrl: "", pageTitle: "", type: "unknown" }); useEffect(() => { - chrome.tabs.query({ active: true, currentWindow: true }, tabs => { + chrome.tabs.query({ active: true, currentWindow: true }, async tabs => { if (tabs.length > 0) { const tab = tabs[0]; if (isGithubPullRequestPage(tab.url!)) { setGithubPage({ pageUrl: tab.url!, pageTitle: tab.title!.split("by")[0].trim(), type: "PR" }); - } else if (isGithubRepoPage(tab.url!)) { + } else if (isGithubRepoPage(tab.url!) && (await isPublicRepository(tab.url!))) { setGithubPage({ pageUrl: tab.url!, pageTitle: "", type: "REPO" }); } } diff --git a/src/utils/dom-utils/prWatcher.ts b/src/utils/dom-utils/prWatcher.ts index ea4453df..91b54df7 100644 --- a/src/utils/dom-utils/prWatcher.ts +++ b/src/utils/dom-utils/prWatcher.ts @@ -1,3 +1,5 @@ +import domUpdateWatch from "./domUpdateWatcher"; + const prEditWatch = (callback: () => void, delayInMs = 0) => { const observer = new MutationObserver((mutationList: MutationRecord[], observer: MutationObserver) => { mutationList.forEach(mutation => { @@ -8,6 +10,11 @@ const prEditWatch = (callback: () => void, delayInMs = 0) => { }); }); + // Disconnect the observer when the user navigates to a new page + domUpdateWatch(() => { + observer.disconnect(); + }); + observer.observe(document.body, { attributes: true, subtree: true }); };