Skip to content

Commit

Permalink
Merge pull request #249 from open-sauced/beta
Browse files Browse the repository at this point in the history
main <- v1.12.1-beta.1
  • Loading branch information
bdougie authored Aug 10, 2023
2 parents 7ad0fdf + 2088458 commit 5ff1f77
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
41 changes: 20 additions & 21 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "opensauced-browser-extension",
"private": true,
"version": "1.12.0",
"version": "1.12.1-beta.1",
"files": [
"dist"
],
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useGetGitHubPageInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
import { isGithubPullRequestPage, isGithubRepoPage } from "../utils/urlMatchers";
import { isPublicRepository } from "../utils/fetchGithubAPIData";

interface GitHubPageInfo {
pageUrl: string;
Expand All @@ -11,13 +12,13 @@ export const usGetGitHubPageInfo = () => {
const [GithubPage, setGithubPage] = useState<GitHubPageInfo>({ 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" });
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/utils/dom-utils/prWatcher.ts
Original file line number Diff line number Diff line change
@@ -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 => {
Expand All @@ -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 });
};

Expand Down

0 comments on commit 5ff1f77

Please sign in to comment.