Skip to content

Commit a32f877

Browse files
committed
Implement title extraction for new issues.
1 parent f616227 commit a32f877

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/lib/enhancers/github/githubIssueNewComment.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface GitHubIssueNewCommentSpot extends CommentSpot {
99
type: 'GH_ISSUE_NEW_COMMENT'
1010
domain: string
1111
slug: string // owner/repo
12+
title: string
1213
}
1314

1415
export class GitHubIssueNewCommentEnhancer implements CommentEnhancer<GitHubIssueNewCommentSpot> {
@@ -17,9 +18,12 @@ export class GitHubIssueNewCommentEnhancer implements CommentEnhancer<GitHubIssu
1718
}
1819

1920
tryToEnhance(
20-
_textarea: HTMLTextAreaElement,
21+
textarea: HTMLTextAreaElement,
2122
location: StrippedLocation,
2223
): GitHubIssueNewCommentSpot | null {
24+
if (textarea.id === 'feedback') {
25+
return null
26+
}
2327
if (location.host !== 'github.com') {
2428
return null
2529
}
@@ -34,9 +38,12 @@ export class GitHubIssueNewCommentEnhancer implements CommentEnhancer<GitHubIssu
3438
const [, owner, repo] = match
3539
const slug = `${owner}/${repo}`
3640
const unique_key = `github.com:${slug}:new`
41+
const titleInput = document.querySelector('input[placeholder="Title"]') as HTMLInputElement
42+
const title = titleInput?.value || ''
3743
return {
3844
domain: location.host,
3945
slug,
46+
title,
4047
type: 'GH_ISSUE_NEW_COMMENT',
4148
unique_key,
4249
}
@@ -62,8 +69,8 @@ export class GitHubIssueNewCommentEnhancer implements CommentEnhancer<GitHubIssu
6269
)
6370
}
6471

65-
tableTitle(_spot: GitHubIssueNewCommentSpot): string {
66-
return 'New Issue'
72+
tableTitle(spot: GitHubIssueNewCommentSpot): string {
73+
return spot.title || 'New Issue'
6774
}
6875

6976
buildUrl(spot: GitHubIssueNewCommentSpot): string {

0 commit comments

Comments
 (0)