Skip to content

Commit 8b6f80b

Browse files
author
ntwigg
committed
More cleanup.
1 parent b9c730e commit 8b6f80b

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

browser-extension/src/datamodel/enhancer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface CommentSpot {
1313
/** wraps the textareas of a given platform with Gitcasso's enhancements */
1414
export interface CommentEnhancer<Spot extends CommentSpot = CommentSpot> {
1515
/** guarantees to only return a type within this list */
16-
forCommentTypes(): string[]
16+
forSpotTypes(): string[]
1717
/**
1818
* whenever a new `textarea` is added to any webpage, this method is called.
1919
* if we return non-null, then we become the handler for that text area.

browser-extension/src/datamodel/enhancers/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface GitHubSpot extends CommentSpot {
2323
}
2424

2525
export class GitHubEnhancer implements CommentEnhancer<GitHubSpot> {
26-
forCommentTypes(): string[] {
26+
forSpotTypes(): string[] {
2727
return [...GITHUB_COMMENT_TYPES]
2828
}
2929

browser-extension/src/datamodel/registries.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ export class EnhancerRegistry {
2121
this.enhancers.add(handler)
2222
}
2323

24-
getHandlerForType(type: string): CommentEnhancer<any> | null {
25-
for (const handler of this.enhancers) {
26-
if (handler.forCommentTypes().includes(type)) {
27-
return handler
28-
}
29-
}
30-
return null
31-
}
32-
3324
tryToEnhance(textarea: HTMLTextAreaElement): EnhancedTextarea<any> | null {
3425
for (const handler of this.enhancers) {
3526
try {
@@ -45,12 +36,8 @@ export class EnhancerRegistry {
4536
return null
4637
}
4738

48-
getAllHandlers(): CommentEnhancer<any>[] {
49-
return Array.from(this.enhancers)
50-
}
51-
52-
getCommentTypesForHandler(handler: CommentEnhancer<any>): string[] {
53-
return handler.forCommentTypes()
39+
getEnhancerCount(): number {
40+
return this.enhancers.size
5441
}
5542
}
5643

browser-extension/src/entrypoints/content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default defineContentScript({
1616
childList: true,
1717
subtree: true,
1818
})
19-
logger.debug('Extension loaded with', enhancers.getAllHandlers().length, 'handlers')
19+
logger.debug('Extension loaded with', enhancers.getEnhancerCount, 'handlers')
2020
},
2121
matches: ['<all_urls>'],
2222
runAt: 'document_end',

0 commit comments

Comments
 (0)