Skip to content

Commit 0161e0b

Browse files
author
ntwigg
committed
Remove unnecessary methods.
1 parent f66e7a9 commit 0161e0b

File tree

4 files changed

+1
-71
lines changed

4 files changed

+1
-71
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,6 @@ export class HandlerRegistry {
3838
return null;
3939
}
4040

41-
identifyAll(): TextareaInfo<any>[] {
42-
const allTextareas: TextareaInfo<any>[] = [];
43-
44-
for (const handler of this.handlers) {
45-
try {
46-
const textareas = handler.identify();
47-
allTextareas.push(...textareas);
48-
} catch (error) {
49-
console.warn('Handler failed to identify textareas:', error);
50-
}
51-
}
52-
53-
return allTextareas;
54-
}
5541

5642
getAllHandlers(): TextareaHandler<any>[] {
5743
return Array.from(this.handlers);

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ export interface TextareaHandler<T extends CommentContext = CommentContext> {
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
1616
identifyContextOf(textarea: HTMLTextAreaElement): TextareaInfo | null;
17-
18-
// Content script functionality
19-
identify(): TextareaInfo<T>[];
20-
readContent(textarea: HTMLTextAreaElement): string;
21-
setContent(textarea: HTMLTextAreaElement, content: string): void;
22-
onSubmit(textarea: HTMLTextAreaElement, callback: (success: boolean) => void): void;
23-
17+
2418
// Context extraction
2519
extractContext(textarea: HTMLTextAreaElement): T | null;
2620
determineType(textarea: HTMLTextAreaElement): string | null;
@@ -40,29 +34,9 @@ export abstract class BaseTextareaHandler<T extends CommentContext = CommentCont
4034

4135
abstract forCommentTypes(): string[];
4236
abstract identifyContextOf(textarea: HTMLTextAreaElement): TextareaInfo<T> | null;
43-
abstract identify(): TextareaInfo<T>[];
4437
abstract extractContext(textarea: HTMLTextAreaElement): T | null;
4538
abstract determineType(textarea: HTMLTextAreaElement): string | null;
4639
abstract generateDisplayTitle(context: T): string;
4740
abstract generateIcon(type: string): string;
4841
abstract buildUrl(context: T, withDraft?: boolean): string;
49-
50-
readContent(textarea: HTMLTextAreaElement): string {
51-
return textarea.value;
52-
}
53-
54-
setContent(textarea: HTMLTextAreaElement, content: string): void {
55-
textarea.value = content;
56-
textarea.dispatchEvent(new Event('input', { bubbles: true }));
57-
textarea.dispatchEvent(new Event('change', { bubbles: true }));
58-
}
59-
60-
onSubmit(textarea: HTMLTextAreaElement, callback: (success: boolean) => void): void {
61-
const form = textarea.closest('form');
62-
if (form) {
63-
form.addEventListener('submit', () => {
64-
setTimeout(() => callback(true), 100);
65-
}, { once: true });
66-
}
67-
}
6842
}

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,6 @@ export class GitHubHandler extends BaseTextareaHandler<GitHubContext> {
4949
return null;
5050
}
5151

52-
identify(): TextareaInfo<GitHubContext>[] {
53-
const textareas = document.querySelectorAll<HTMLTextAreaElement>('textarea');
54-
const results: TextareaInfo<GitHubContext>[] = [];
55-
56-
for (const textarea of textareas) {
57-
const type = this.determineType(textarea);
58-
const context = this.extractContext(textarea);
59-
60-
if (type && context) {
61-
results.push({ element: textarea, type, context });
62-
}
63-
}
64-
65-
return results;
66-
}
6752

6853
extractContext(textarea: HTMLTextAreaElement): GitHubContext | null {
6954
const pathname = window.location.pathname;

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,6 @@ export class RedditHandler extends BaseTextareaHandler<RedditContext> {
4040
return null;
4141
}
4242

43-
identify(): TextareaInfo<RedditContext>[] {
44-
const textareas = document.querySelectorAll<HTMLTextAreaElement>('textarea');
45-
const results: TextareaInfo<RedditContext>[] = [];
46-
47-
for (const textarea of textareas) {
48-
const type = this.determineType(textarea);
49-
const context = this.extractContext(textarea);
50-
51-
if (type && context) {
52-
results.push({ element: textarea, type, context });
53-
}
54-
}
55-
56-
return results;
57-
}
5843

5944
extractContext(textarea: HTMLTextAreaElement): RedditContext | null {
6045
const pathname = window.location.pathname;

0 commit comments

Comments
 (0)