File tree Expand file tree Collapse file tree 1 file changed +24
-21
lines changed 
browser-extension/src/entrypoints Expand file tree Collapse file tree 1 file changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -16,31 +16,34 @@ interface CommentState {
1616} 
1717
1818const  states  =  new  JsonMap < TabAndSpot ,  CommentState > ( ) 
19- browser . runtime . onMessage . addListener ( ( message : CommentEvent ,  sender )  =>  { 
20-   if  ( 
21-     ( message . type  ===  'ENHANCED'  ||  message . type  ===  'DESTROYED' )  && 
22-     sender . tab ?. id  && 
23-     sender . tab ?. windowId 
24-   )  { 
25-     const  tab : Tab  =  { 
26-       tabId : sender . tab . id , 
27-       windowId : sender . tab . windowId , 
28-     } 
2919
30-     const  tabAndSpot : TabAndSpot  =  { 
31-       spot : message . spot , 
32-       tab, 
33-     } 
20+ export  default  defineBackground ( ( )  =>  { 
21+   browser . runtime . onMessage . addListener ( ( message : CommentEvent ,  sender )  =>  { 
22+     if  ( 
23+       ( message . type  ===  'ENHANCED'  ||  message . type  ===  'DESTROYED' )  && 
24+       sender . tab ?. id  && 
25+       sender . tab ?. windowId 
26+     )  { 
27+       const  tab : Tab  =  { 
28+         tabId : sender . tab . id , 
29+         windowId : sender . tab . windowId , 
30+       } 
3431
35-     if  ( message . type  ===  'ENHANCED' )  { 
36-       const  commentState : CommentState  =  { 
37-         drafts : [ ] , 
32+       const  tabAndSpot : TabAndSpot  =  { 
3833        spot : message . spot , 
3934        tab, 
4035      } 
41-       states . set ( tabAndSpot ,  commentState ) 
42-     }  else  if  ( message . type  ===  'DESTROYED' )  { 
43-       states . delete ( tabAndSpot ) 
36+ 
37+       if  ( message . type  ===  'ENHANCED' )  { 
38+         const  commentState : CommentState  =  { 
39+           drafts : [ ] , 
40+           spot : message . spot , 
41+           tab, 
42+         } 
43+         states . set ( tabAndSpot ,  commentState ) 
44+       }  else  if  ( message . type  ===  'DESTROYED' )  { 
45+         states . delete ( tabAndSpot ) 
46+       } 
4447    } 
45-   } 
48+   } ) 
4649} ) 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments