@@ -398,7 +398,7 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) =
398398 composeModal ?. remove ( ) ;
399399 composeModal = null ;
400400
401- setTimeout ( ( ) => fetchAnnotations ( ) , 500 ) ;
401+ setTimeout ( ( ) => fetchAnnotations ( 0 , true ) , 500 ) ;
402402 } catch ( error ) {
403403 console . error ( 'Failed to create annotation:' , error ) ;
404404 showToast ( 'Failed to create annotation' , 'error' ) ;
@@ -415,7 +415,7 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) =
415415 showComposeModal ( message . data . selector . exact ) ;
416416 }
417417 if ( message . type === 'REFRESH_ANNOTATIONS' ) {
418- fetchAnnotations ( ) ;
418+ fetchAnnotations ( 0 , true ) ;
419419 }
420420 if ( message . type === 'SCROLL_TO_TEXT' && message . text ) {
421421 scrollToText ( message . text ) ;
@@ -512,14 +512,17 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) =
512512 } , 2500 ) ;
513513 }
514514
515- async function fetchAnnotations ( retryCount = 0 ) {
515+ async function fetchAnnotations ( retryCount = 0 , cacheBust = false ) {
516516 if ( ! overlayEnabled ) {
517517 sendMessage ( 'updateBadge' , { count : 0 } ) ;
518518 return ;
519519 }
520520
521521 try {
522- const annotations = await sendMessage ( 'getAnnotations' , { url : getPageUrl ( ) } ) ;
522+ const annotations = await sendMessage ( 'getAnnotations' , {
523+ url : getPageUrl ( ) ,
524+ cacheBust,
525+ } ) ;
523526
524527 sendMessage ( 'updateBadge' , { count : annotations ?. length || 0 } ) ;
525528
@@ -530,12 +533,12 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) =
530533 if ( annotations && annotations . length > 0 ) {
531534 renderBadges ( annotations ) ;
532535 } else if ( retryCount < 3 ) {
533- setTimeout ( ( ) => fetchAnnotations ( retryCount + 1 ) , 1000 * ( retryCount + 1 ) ) ;
536+ setTimeout ( ( ) => fetchAnnotations ( retryCount + 1 , cacheBust ) , 1000 * ( retryCount + 1 ) ) ;
534537 }
535538 } catch ( error ) {
536539 console . error ( 'Failed to fetch annotations:' , error ) ;
537540 if ( retryCount < 3 ) {
538- setTimeout ( ( ) => fetchAnnotations ( retryCount + 1 ) , 1000 * ( retryCount + 1 ) ) ;
541+ setTimeout ( ( ) => fetchAnnotations ( retryCount + 1 , cacheBust ) , 1000 * ( retryCount + 1 ) ) ;
539542 }
540543 }
541544 }
0 commit comments