@@ -468,6 +468,35 @@ export class GlSettingsPreview extends SignalWatcher(LitElement) {
468468 . catch ( ( ) => { } ) ;
469469 } , 200 ) ;
470470
471+ override willUpdate ( ) : void {
472+ // Trigger the (debounced) host preview fetches here, not in render(), so
473+ // render stays side-effect-free. Only the two annotation-bearing previews
474+ // need them; the composite key re-fetches when the format or any setting
475+ // the host formatter reads (PR toggle, default date format) changes. Signal
476+ // reads here are tracked the same as in render (SignalWatcher).
477+ if ( this . actions == null ) return ;
478+
479+ if ( this . kind === 'blame' && ( this . get < boolean > ( 'currentLine.enabled' ) ?? false ) ) {
480+ const format = this . get < string > ( 'currentLine.format' ) ?? '' ;
481+ const key = `${ format } \n${ this . get < boolean > ( 'currentLine.pullRequests.enabled' ) ?? false } \n${
482+ this . get < string > ( 'defaultDateFormat' ) ?? ''
483+ } `;
484+ if ( key !== this . _lastBlameKey ) {
485+ this . _lastBlameKey = key ;
486+ this . fetchBlameAnnotation ( format ) ;
487+ }
488+ } else if ( this . kind === 'statusbar' && ( this . get < boolean > ( 'statusBar.enabled' ) ?? false ) ) {
489+ const format = this . get < string > ( 'statusBar.format' ) ?? '' ;
490+ const key = `${ format } \n${ this . get < boolean > ( 'statusBar.pullRequests.enabled' ) ?? false } \n${
491+ this . get < string > ( 'defaultDateFormat' ) ?? ''
492+ } `;
493+ if ( key !== this . _lastStatusBarKey ) {
494+ this . _lastStatusBarKey = key ;
495+ this . fetchStatusBarText ( format ) ;
496+ }
497+ }
498+ }
499+
471500 override render ( ) : unknown {
472501 switch ( this . kind ) {
473502 case 'blame' :
@@ -529,19 +558,6 @@ export class GlSettingsPreview extends SignalWatcher(LitElement) {
529558
530559 private renderBlame ( ) {
531560 const on = this . get < boolean > ( 'currentLine.enabled' ) ?? false ;
532- const format = this . get < string > ( 'currentLine.format' ) ?? '' ;
533-
534- if ( on && this . actions != null ) {
535- // The host preview also reads pullRequests.enabled and defaultDateFormat, so re-fetch when
536- // any of those change — not just the format string (and only once actions are wired up)
537- const key = `${ format } \n${ this . get < boolean > ( 'currentLine.pullRequests.enabled' ) ?? false } \n${
538- this . get < string > ( 'defaultDateFormat' ) ?? ''
539- } `;
540- if ( key !== this . _lastBlameKey ) {
541- this . _lastBlameKey = key ;
542- this . fetchBlameAnnotation ( format ) ;
543- }
544- }
545561
546562 return this . renderEditorChrome (
547563 html `< div class ="code ">
@@ -583,19 +599,8 @@ export class GlSettingsPreview extends SignalWatcher(LitElement) {
583599
584600 private renderStatusBar ( ) {
585601 const on = this . get < boolean > ( 'statusBar.enabled' ) ?? false ;
586- const format = this . get < string > ( 'statusBar.format' ) ?? '' ;
587602 const right = ( this . get < string > ( 'statusBar.alignment' ) ?? 'right' ) === 'right' ;
588603
589- if ( on && this . actions != null ) {
590- const key = `${ format } \n${ this . get < boolean > ( 'statusBar.pullRequests.enabled' ) ?? false } \n${
591- this . get < string > ( 'defaultDateFormat' ) ?? ''
592- } `;
593- if ( key !== this . _lastStatusBarKey ) {
594- this . _lastStatusBarKey = key ;
595- this . fetchStatusBarText ( format ) ;
596- }
597- }
598-
599604 const blame = on
600605 ? html `< span class ="statusbar__item "
601606 > < code-icon icon ="gl-gitlens " aria-hidden ="true "> </ code-icon > ${ this . _statusBarText ?? '…' } </ span
0 commit comments