Skip to content

Commit 4bdb01d

Browse files
committed
Undo refactoring for single-use-site functions.
1 parent 254bbd9 commit 4bdb01d

File tree

4 files changed

+14
-32
lines changed

4 files changed

+14
-32
lines changed

src/lib/enhancers/github/GitHubEditEnhancer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { logger } from "@/lib/logger"
99
import { fixupOvertype, modifyDOM } from "../overtype-misc"
1010
import {
1111
commonGitHubOptions,
12-
isProjectUrl,
1312
isInProjectCommentBox,
13+
isProjectUrl,
1414
parseProjectIssueParam,
1515
prepareGitHubHighlighter,
1616
} from "./github-common"

src/lib/enhancers/github/GitHubIssueAppendEnhancer.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import { logger } from "@/lib/logger"
1111
import { fixupOvertype, modifyDOM } from "../overtype-misc"
1212
import {
1313
commonGitHubOptions,
14-
extractProjectIssueTitle,
15-
isProjectUrl,
1614
isInProjectCommentBox,
15+
isProjectUrl,
1716
parseProjectIssueParam,
1817
prepareGitHubHighlighter,
1918
} from "./github-common"
@@ -29,7 +28,8 @@ export interface GitHubIssueAppendSpot extends CommentSpot {
2928
}
3029

3130
export class GitHubIssueAppendEnhancer
32-
implements CommentEnhancer<GitHubIssueAppendSpot> {
31+
implements CommentEnhancer<GitHubIssueAppendSpot>
32+
{
3333
forSpotTypes(): string[] {
3434
return [GH_ISSUE_APPEND]
3535
}
@@ -60,7 +60,10 @@ export class GitHubIssueAppendEnhancer
6060
if (issueInfo) {
6161
const unique_key = `github.com:${issueInfo.slug}:${issueInfo.number}`
6262
// For project views, the title is in the side panel dialog
63-
const title = extractProjectIssueTitle()
63+
const title =
64+
document
65+
.querySelector('[data-testid="issue-title"]')
66+
?.textContent?.trim() || ""
6467
return {
6568
domain: location.host,
6669
number: issueInfo.number,

src/lib/enhancers/github/GitHubIssueCreateEnhancer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { logger } from "../../logger"
1010
import { fixupOvertype, modifyDOM } from "../overtype-misc"
1111
import {
1212
commonGitHubOptions,
13-
extractDialogSlug,
1413
isProjectUrl,
1514
prepareGitHubHighlighter,
1615
} from "./github-common"
@@ -25,7 +24,8 @@ export interface GitHubIssueCreateSpot extends CommentSpot {
2524
}
2625

2726
export class GitHubIssueCreateEnhancer
28-
implements CommentEnhancer<GitHubIssueCreateSpot> {
27+
implements CommentEnhancer<GitHubIssueCreateSpot>
28+
{
2929
forSpotTypes(): string[] {
3030
return [GH_ISSUE_CREATE]
3131
}
@@ -46,8 +46,10 @@ export class GitHubIssueCreateEnhancer
4646
// Check if we're in a "Create new issue" dialog
4747
const dialog = textarea.closest('[role="dialog"]')
4848
if (dialog) {
49-
const slug = extractDialogSlug(dialog)
50-
if (slug) {
49+
const dialogHeading = dialog.querySelector("h1")?.textContent
50+
const slugMatch = dialogHeading?.match(/Create new issue in (.+)/)
51+
if (slugMatch) {
52+
const slug = slugMatch[1]!
5153
const unique_key = `github.com:${slug}:new`
5254
const titleInput = document.querySelector(
5355
'input[placeholder="Title"]'

src/lib/enhancers/github/github-common.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,3 @@ export function parseProjectIssueParam(
107107
export function isInProjectCommentBox(element: HTMLElement): boolean {
108108
return !!element.closest('[class*="Shared-module__CommentBox"]')
109109
}
110-
111-
/**
112-
* Extract the issue title from a project view.
113-
* Used when viewing issues within a project board.
114-
*/
115-
export function extractProjectIssueTitle(): string {
116-
return (
117-
document
118-
.querySelector('[data-testid="issue-title"]')
119-
?.textContent?.trim() || ""
120-
)
121-
}
122-
123-
/**
124-
* Extract the repository slug from a "Create new issue" dialog heading.
125-
* Heading format: "Create new issue in owner/repo"
126-
* Returns: "owner/repo" or null if not found
127-
*/
128-
export function extractDialogSlug(dialog: Element): string | null {
129-
const dialogHeading = dialog.querySelector("h1")?.textContent
130-
const slugMatch = dialogHeading?.match(/Create new issue in (.+)/)
131-
return slugMatch ? slugMatch[1]! : null
132-
}

0 commit comments

Comments
 (0)