@@ -21,19 +21,19 @@ const iconsDisabled = {
2121}
2222
2323const twitchUrlRegexp = / ^ h t t p s : \/ \/ w w w .t w i t c h .t v \/ * / ;
24- const TEN_MINUTES_MS = 10 * 60 * 1000 ;
24+ const TEN_SECONDS_MS = 10 * 1000 ;
2525
2626const throttledSetPoints = ( setChannelPointsFn ) => {
2727 const calls = { } ;
2828 return async ( channelId , points ) => {
2929 if ( ! calls [ channelId ] ) {
30- calls [ channelId ] = Date . now ( ) - TEN_MINUTES_MS - 1 ;
30+ calls [ channelId ] = Date . now ( ) - TEN_SECONDS_MS - 1 ;
3131 }
3232
3333 const now = Date . now ( ) ;
3434 const lastTime = calls [ channelId ] ;
3535
36- if ( now - lastTime >= TEN_MINUTES_MS ) {
36+ if ( now - lastTime >= TEN_SECONDS_MS ) {
3737 calls [ channelId ] = now ;
3838 return setChannelPointsFn ( channelId , points ) ;
3939 }
@@ -82,7 +82,7 @@ const Extension = () => {
8282 } ;
8383
8484 const updateBadgeForChannel = async ( { channelId, tabId } ) => {
85- const points = state . channelPoints [ channelId ] || 0 ;
85+ const points = getChannelPoints ( channelId ) ;
8686 if ( tabId ) {
8787 browser . browserAction . setBadgeText ( {
8888 text : String ( points ) ,
@@ -131,6 +131,7 @@ const Extension = () => {
131131 setEnabled : async ( value ) => {
132132 await browser . storage . local . set ( { isEnabled : value } ) ;
133133 await updateTab ( { isEnabled : value } ) ;
134+ updateExtensionIcon ( value ) ;
134135 state . isEnabled = value ;
135136 }
136137 }
@@ -184,9 +185,8 @@ browser.tabs.onRemoved.addListener((tabId) => {
184185const onContentScriptMessage = async ( message , sender ) => {
185186 if ( sender . id === browser . runtime . id ) {
186187 if ( message . type === 'add_points' ) {
187- const currentState = await browser . storage . local . get ( ) ;
188188 const channelId = new URL ( sender . url ) . pathname . split ( '/' ) . pop ( ) ;
189- const pointsCollectedForChannel = currentState [ channelId ] || 0 ;
189+ const pointsCollectedForChannel = extension . getChannelPoints ( channelId ) ;
190190 const updatedAmount = pointsCollectedForChannel + message . bonus ;
191191 extension . setChannelPoints ( channelId , updatedAmount ) ;
192192 }
0 commit comments