Skip to content

Commit b25cb3d

Browse files
committed
strip down the githubEditComment to the basics
1 parent f30d185 commit b25cb3d

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed
Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,32 @@
11
import OverType, { type OverTypeInstance } from 'overtype'
22
import type React from 'react'
3-
import type { CommentEnhancer, CommentSpot } from '@/lib/enhancer'
3+
import type { CommentEnhancer, CommentSpot, StrippedLocation } from '@/lib/enhancer'
44
import { logger } from '@/lib/logger'
55
import { modifyDOM } from '../modifyDOM'
66
import { commonGithubOptions } from './ghOptions'
77
import { prepareGitHubHighlighter } from './githubHighlighter'
88

99
export interface GitHubEditCommentSpot extends CommentSpot {
1010
type: 'GH_EDIT_COMMENT'
11-
title: string
12-
domain: string
13-
slug: string
14-
number: number
1511
}
1612

1713
export class GitHubEditCommentEnhancer implements CommentEnhancer<GitHubEditCommentSpot> {
1814
forSpotTypes(): string[] {
1915
return ['GH_EDIT_COMMENT']
2016
}
2117

22-
tryToEnhance(_textarea: HTMLTextAreaElement): GitHubEditCommentSpot | null {
23-
if (
24-
document.querySelector('meta[name="hostname"]')?.getAttribute('content') !== 'github.com' ||
25-
!_textarea.matches('.TimelineItem textarea')
26-
) {
18+
tryToEnhance(
19+
_textarea: HTMLTextAreaElement,
20+
location: StrippedLocation,
21+
): GitHubEditCommentSpot | null {
22+
if (location.host !== 'github.com') {
2723
return null
2824
}
29-
3025
// Parse GitHub URL structure: /owner/repo/issues/123 or /owner/repo/pull/456
3126
logger.info(`${this.constructor.name} examing url`, window.location.pathname)
32-
33-
const match = window.location.pathname.match(/^\/([^/]+)\/([^/]+)(?:\/(pull|issues)\/(\d+))/)
34-
logger.info(`${this.constructor.name} found match`, window.location.pathname)
35-
if (!match) return null
36-
const [, owner, repo, numberStr] = match
37-
const slug = `${owner}/${repo}`
38-
const number = parseInt(numberStr!, 10)
39-
const unique_key = `github.com:${slug}:${number}`
40-
const title = 'TODO_TITLE'
4127
return {
42-
domain: 'github.com',
43-
number,
44-
slug,
45-
title,
4628
type: 'GH_EDIT_COMMENT',
47-
unique_key,
29+
unique_key: '<not unique>',
4830
}
4931
}
5032

@@ -59,17 +41,11 @@ export class GitHubEditCommentEnhancer implements CommentEnhancer<GitHubEditComm
5941
})[0]!
6042
}
6143

62-
tableUpperDecoration(spot: GitHubEditCommentSpot): React.ReactNode {
63-
const { slug, number } = spot
64-
return (
65-
<>
66-
<span className='font-mono text-muted-foreground text-sm'>{slug}</span>
67-
<span className='ml-2 font-medium'>PR #{number}</span>
68-
</>
69-
)
44+
tableUpperDecoration(_spot: GitHubEditCommentSpot): React.ReactNode {
45+
return <span>N/A</span>
7046
}
7147

7248
tableTitle(_spot: GitHubEditCommentSpot): string {
73-
return 'TITLE_TODO'
49+
return 'N/A'
7450
}
7551
}

0 commit comments

Comments
 (0)