File tree Expand file tree Collapse file tree 4 files changed +5
-18
lines changed
Expand file tree Collapse file tree 4 files changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export interface CommentSpot {
1313/** wraps the textareas of a given platform with Gitcasso's enhancements */
1414export 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.
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export interface GitHubSpot extends CommentSpot {
2323}
2424
2525export class GitHubEnhancer implements CommentEnhancer < GitHubSpot > {
26- forCommentTypes ( ) : string [ ] {
26+ forSpotTypes ( ) : string [ ] {
2727 return [ ...GITHUB_COMMENT_TYPES ]
2828 }
2929
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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' ,
You can’t perform that action at this time.
0 commit comments