@@ -19,6 +19,8 @@ import { useMemo, useState } from 'react'
1919import { twMerge } from 'tailwind-merge'
2020import type { CommentSpot } from '@/lib/enhancer'
2121import type { DraftStats } from '@/lib/enhancers/draftStats'
22+ import type { GitHubIssueAddCommentSpot } from '@/lib/enhancers/github/githubIssueAddComment'
23+ import type { GitHubPRAddCommentSpot } from '@/lib/enhancers/github/githubPRAddComment'
2224
2325interface FilterState {
2426 sentFilter : 'both' | 'sent' | 'unsent'
@@ -146,30 +148,6 @@ const MultiSegment = <T,>({ segments, value, onValueChange }: MultiSegmentProps<
146148 )
147149}
148150
149- /*
150- interface GitHubIssueAddCommentSpot extends CommentSpot {
151- type: 'GH_ISSUE_ADD_COMMENT'
152- domain: 'string'
153- slug: string // owner/repo
154- number: number // issue number, undefined for new issues
155- title: string
156- }
157- export interface GitHubPRAddCommentSpot extends CommentSpot {
158- type: 'GH_PR_ADD_COMMENT' // Override to narrow from string to specific union
159- domain: string
160- slug: string // owner/repo
161- number: number // issue/PR number, undefined for new issues and PRs
162- title: string
163- }
164- */
165-
166- interface GitHubSpot extends CommentSpot {
167- title : string
168- slug : string
169- number : number
170- type : 'PR' | 'ISSUE'
171- }
172-
173151interface RedditSpot extends CommentSpot {
174152 title : string
175153 subreddit : string
@@ -190,10 +168,10 @@ interface CommentTableRow {
190168 isTrashed : boolean
191169}
192170
193- type GitHubOrReddit = GitHubSpot | RedditSpot
171+ type GitHubOrReddit = GitHubIssueAddCommentSpot | GitHubPRAddCommentSpot | RedditSpot
194172
195- const isGitHubDraft = ( spot : GitHubOrReddit ) : spot is GitHubSpot => {
196- return spot . type === 'PR ' || spot . type === 'ISSUE '
173+ const isGitHubDraft = ( spot : GitHubOrReddit ) : spot is GitHubIssueAddCommentSpot => {
174+ return spot . type === 'GH_PR_ADD_COMMENT ' || spot . type === 'GH_ISSUE_ADD_COMMENT '
197175}
198176
199177const isRedditDraft = ( spot : GitHubOrReddit ) : spot is RedditSpot => {
@@ -227,12 +205,13 @@ const generateMockDrafts = (): CommentTableRow[] => [
227205 time : Date . now ( ) - 1000 * 60 * 30 ,
228206 } ,
229207 spot : {
208+ domain : 'github.com' ,
230209 number : 1234 ,
231210 slug : 'microsoft/vscode' ,
232211 title : "Fix memory leak in extension host (why is this so hard! It's been months!)" ,
233- type : 'PR ' ,
212+ type : 'GH_PR_ADD_COMMENT ' ,
234213 unique_key : '1' ,
235- } satisfies GitHubSpot ,
214+ } satisfies GitHubPRAddCommentSpot ,
236215 } ,
237216 {
238217 isOpenTab : false ,
@@ -277,12 +256,13 @@ const generateMockDrafts = (): CommentTableRow[] => [
277256 time : Date . now ( ) - 1000 * 60 * 60 * 5 ,
278257 } ,
279258 spot : {
259+ domain : 'github.com' ,
280260 number : 5678 ,
281261 slug : 'facebook/react' ,
282262 title : 'Unexpected behavior with useEffect cleanup' ,
283- type : 'ISSUE ' ,
263+ type : 'GH_ISSUE_ADD_COMMENT ' ,
284264 unique_key : '3' ,
285- } satisfies GitHubSpot ,
265+ } satisfies GitHubIssueAddCommentSpot ,
286266 } ,
287267 {
288268 isOpenTab : false ,
@@ -312,12 +292,13 @@ const generateMockDrafts = (): CommentTableRow[] => [
312292 time : Date . now ( ) - 1000 * 60 * 60 * 24 ,
313293 } ,
314294 spot : {
295+ domain : 'github' ,
315296 number : 9012 ,
316297 slug : 'vercel/next.js' ,
317298 title : 'Update routing documentation' ,
318- type : 'PR ' ,
299+ type : 'GH_PR_ADD_COMMENT ' ,
319300 unique_key : '4' ,
320- } satisfies GitHubSpot ,
301+ } satisfies GitHubPRAddCommentSpot ,
321302 } ,
322303 {
323304 isOpenTab : true ,
@@ -352,12 +333,13 @@ const generateMockDrafts = (): CommentTableRow[] => [
352333 time : Date . now ( ) - 1000 * 60 * 60 * 48 ,
353334 } ,
354335 spot : {
336+ domain : 'github.com' ,
355337 number : 3456 ,
356338 slug : 'nodejs/node' ,
357339 title : 'Add support for ESM in worker threads' ,
358- type : 'PR ' ,
340+ type : 'GH_PR_ADD_COMMENT ' ,
359341 unique_key : '5' ,
360- } satisfies GitHubSpot ,
342+ } satisfies GitHubPRAddCommentSpot ,
361343 } ,
362344]
363345
@@ -609,8 +591,8 @@ function commentRow(
609591 < div className = 'flex items-center justify-between gap-1.5 text-xs text-gray-600' >
610592 < div className = 'flex items-center gap-1.5 min-w-0 flex-1' >
611593 < span className = 'w-4 h-4 flex items-center justify-center flex-shrink-0' >
612- { row . spot . type === 'PR ' && < GitPullRequestIcon size = { 16 } /> }
613- { row . spot . type === 'ISSUE ' && < IssueOpenedIcon size = { 16 } /> }
594+ { row . spot . type === 'GH_PR_ADD_COMMENT ' && < GitPullRequestIcon size = { 16 } /> }
595+ { row . spot . type === 'GH_ISSUE_ADD_COMMENT ' && < IssueOpenedIcon size = { 16 } /> }
614596 { row . spot . type === 'REDDIT' && (
615597 < img
616598 src = 'https://styles.redditmedia.com/t5_2fwo/styles/communityIcon_1bqa1ibfp8q11.png?width=128& frame = 1 & auto = webp & s = 400 b33e7080aa4996c405a96b3872a12f0e3b68d '
0 commit comments