Skip to content

Commit c53b60d

Browse files
author
ntwigg
committed
More refactor cleanup.
1 parent d35d4ae commit c53b60d

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

browser-extension/src/datamodel/handler-registry.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export class HandlerRegistry {
2727
identifyTextarea(textarea: HTMLTextAreaElement): TextareaInfo<any> | null {
2828
for (const handler of this.handlers) {
2929
try {
30-
const result = handler.identifyContextOf(textarea);
31-
if (result) {
32-
return result;
30+
const context = handler.identifyContextOf(textarea);
31+
if (context) {
32+
return { element: textarea, context };
3333
}
3434
} catch (error) {
3535
console.warn('Handler failed to identify textarea:', error);

browser-extension/src/datamodel/textarea-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface TextareaHandler<T extends CommentContext = CommentContext> {
1313
// Handler metadata
1414
forCommentTypes(): string[];
1515
// whenever a new `textarea` is added to any webpage, this method is called to try to find a handler for it
16-
identifyContextOf(textarea: HTMLTextAreaElement): TextareaInfo | null;
16+
identifyContextOf(textarea: HTMLTextAreaElement): T | null;
1717

1818
// Popup functionality helpers
1919
generateDisplayTitle(context: T): string;

browser-extension/src/handlers/github-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class GitHubHandler implements TextareaHandler<GitHubContext> {
3030
];
3131
}
3232

33-
identifyContextOf(textarea: HTMLTextAreaElement): TextareaInfo<GitHubContext> | null {
33+
identifyContextOf(textarea: HTMLTextAreaElement): GitHubContext | null {
3434
// Only handle GitHub domains
3535
if (!window.location.hostname.includes('github')) {
3636
return null;
@@ -102,7 +102,7 @@ export class GitHubHandler implements TextareaHandler<GitHubContext> {
102102
commentId: commentId || undefined
103103
};
104104

105-
return { element: textarea, context };
105+
return context;
106106
}
107107

108108
generateDisplayTitle(context: GitHubContext): string {

browser-extension/src/handlers/reddit-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class RedditHandler implements TextareaHandler<RedditContext> {
2121
];
2222
}
2323

24-
identifyContextOf(textarea: HTMLTextAreaElement): TextareaInfo<RedditContext> | null {
24+
identifyContextOf(textarea: HTMLTextAreaElement): RedditContext | null {
2525
// Only handle Reddit domains
2626
if (!window.location.hostname.includes('reddit')) {
2727
return null;
@@ -87,7 +87,7 @@ export class RedditHandler implements TextareaHandler<RedditContext> {
8787
commentId: commentId || undefined
8888
};
8989

90-
return { element: textarea, context };
90+
return context;
9191
}
9292

9393
generateDisplayTitle(context: RedditContext): string {

0 commit comments

Comments
 (0)