diff options
-rw-r--r-- | source/features/add-tag-to-commits.tsx | 7 | ||||
-rw-r--r-- | source/features/bugs-tab.tsx | 2 | ||||
-rw-r--r-- | source/features/esc-to-deselect-line.tsx | 5 | ||||
-rw-r--r-- | source/features/recently-pushed-branches-enhancements.tsx | 2 | ||||
-rw-r--r-- | source/features/revert-file.tsx | 11 | ||||
-rw-r--r-- | source/features/selection-in-new-tab.tsx | 2 | ||||
-rw-r--r-- | source/features/show-names.tsx | 2 |
7 files changed, 17 insertions, 14 deletions
diff --git a/source/features/add-tag-to-commits.tsx b/source/features/add-tag-to-commits.tsx index 05048c82..48d739b7 100644 --- a/source/features/add-tag-to-commits.tsx +++ b/source/features/add-tag-to-commits.tsx @@ -6,7 +6,7 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; -import {getOwnerAndRepo, getRepoURL, getRepoGQL} from '../github-helpers'; +import {getRepoURL, getRepoGQL} from '../github-helpers'; interface CommitTags { [name: string]: string[]; @@ -32,9 +32,6 @@ interface TagNode { target: CommonTarget; } -const {ownerName, repoName} = getOwnerAndRepo(); -const cacheKey = `tags:${ownerName!}/${repoName!}`; - function mergeTags(oldTags: CommitTags, newTags: CommitTags): CommitTags { const result: CommitTags = {...oldTags}; for (const commit in newTags) { @@ -121,6 +118,8 @@ async function getTags(lastCommit: string, after?: string): Promise<CommitTags> } async function init(): Promise<void | false> { + const cacheKey = `tags:${getRepoURL()}`; + const commitsOnPage = select.all('li.commit'); const lastCommitOnPage = (commitsOnPage[commitsOnPage.length - 1].dataset.channel as string).split(':')[3]; let cached = await cache.get<{[commit: string]: string[]}>(cacheKey) ?? {}; diff --git a/source/features/bugs-tab.tsx b/source/features/bugs-tab.tsx index fe307128..5c854a75 100644 --- a/source/features/bugs-tab.tsx +++ b/source/features/bugs-tab.tsx @@ -71,7 +71,7 @@ async function init(): Promise<void | false> { new SearchQuery(bugsLink).add('label:bug'); // Change the Selected tab if necessary - bugsLink.classList.toggle('selected', isBugsPage); + bugsLink.classList.toggle('selected', isBugsPage && !pageDetect.isPRList()); select('.selected', issuesTab)?.classList.toggle('selected', !isBugsPage); issuesTab.after(bugsTab); diff --git a/source/features/esc-to-deselect-line.tsx b/source/features/esc-to-deselect-line.tsx index 05043a1e..34691042 100644 --- a/source/features/esc-to-deselect-line.tsx +++ b/source/features/esc-to-deselect-line.tsx @@ -1,3 +1,5 @@ +import * as pageDetect from 'github-url-detection'; + import features from '.'; import {isEditable} from '../helpers/dom-utils'; @@ -29,6 +31,9 @@ features.add({ description: 'Adds a keyboard shortcut to deselect the current line: `esc`.', screenshot: false }, { + include: [ + pageDetect.hasCode + ], waitForDomReady: false, repeatOnAjax: false, init diff --git a/source/features/recently-pushed-branches-enhancements.tsx b/source/features/recently-pushed-branches-enhancements.tsx index dfb1e078..98c8ebc6 100644 --- a/source/features/recently-pushed-branches-enhancements.tsx +++ b/source/features/recently-pushed-branches-enhancements.tsx @@ -48,7 +48,7 @@ async function init(): Promise<false | void> { document.body.classList.add('rgh-recently-pushed-branches'); // Move or add list next to the notifications bell - select('.Header-item--full,.HeaderMenu nav')!.after(widget); + select.last('.Header-item--full,.HeaderMenu nav')!.after(widget); } features.add({ diff --git a/source/features/revert-file.tsx b/source/features/revert-file.tsx index 4b5597ce..76bff233 100644 --- a/source/features/revert-file.tsx +++ b/source/features/revert-file.tsx @@ -31,8 +31,7 @@ const getBaseReference = onetime(async (): Promise<string> => { return repository.pullRequest.baseRefOid; }); -async function getFile(menuItem: Element): Promise<{isTruncated: boolean; text: string} | null> { - const filePath = menuItem.closest<HTMLElement>('[data-path]')!.dataset.path!; +async function getFile(filePath: string): Promise<{isTruncated: boolean; text: string} | null> { const {repository} = await api.v4(` repository(${getRepoGQL()}) { file: object(expression: "${await getBaseReference()}:${filePath}") { @@ -54,12 +53,11 @@ async function deleteFile(menuItem: Element): Promise<void> { await postForm(form!); } -async function commitFileContent(menuItem: Element, content: string): Promise<void> { +async function commitFileContent(menuItem: Element, content: string, filePath: string): Promise<void> { let {pathname} = menuItem.previousElementSibling as HTMLAnchorElement; // Check if file was deleted by PR if (menuItem.closest('[data-file-deleted="true"]')) { menuItem.textContent = 'Undeleting…'; - const filePath = pathname.split('/')[5]; // The URL was something like /$user/$repo/blob/$startingCommit/$path pathname = `/${getRepoURL()}/new/${getCurrentBranch()}?filename=` + filePath; } else { menuItem.textContent = 'Committing…'; @@ -90,7 +88,8 @@ async function handleRevertFileClick(event: delegate.Event<MouseEvent, HTMLButto event.stopPropagation(); try { - const file = await getFile(menuItem); + const filePath = menuItem.closest<HTMLDivElement>('[data-path]')!.dataset.path!; + const file = await getFile(filePath); if (!file) { // The file was created by this PR. Revert === Delete. @@ -104,7 +103,7 @@ async function handleRevertFileClick(event: delegate.Event<MouseEvent, HTMLButto return; } - await commitFileContent(menuItem, file.text); + await commitFileContent(menuItem, file.text, filePath); // Hide file from view menuItem.closest('.file')!.remove(); diff --git a/source/features/selection-in-new-tab.tsx b/source/features/selection-in-new-tab.tsx index 3bf8d159..feba040a 100644 --- a/source/features/selection-in-new-tab.tsx +++ b/source/features/selection-in-new-tab.tsx @@ -12,7 +12,7 @@ function init(): void { }); // Get the list element that contains the unread class and mark it as read. - selected.closest('li')!.classList.replace('unread', 'read'); + selected.closest('.unread')?.classList.replace('unread', 'read'); } }); } diff --git a/source/features/show-names.tsx b/source/features/show-names.tsx index 593b6775..48ca1220 100644 --- a/source/features/show-names.tsx +++ b/source/features/show-names.tsx @@ -9,7 +9,7 @@ import {getUsername, compareNames} from '../github-helpers'; async function init(): Promise<false | void> { const usernameElements = select.all([ - '.js-discussion a.author:not(.rgh-fullname):not([href*="/marketplace/"]):not([data-hovercard-type="organization"])', // `a` selector needed to skip commits by non-GitHub users. + '.js-discussion a.author:not(.rgh-fullname):not([href*="/apps/"]):not([href*="/marketplace/"]):not([data-hovercard-type="organization"])', // `a` selector needed to skip commits by non-GitHub users. '#dashboard a.text-bold[data-hovercard-type="user"]:not(.rgh-fullname)' // On dashboard `.text-bold` is required to not fetch avatars. ]); |