11import { consume } from '@lit/context' ;
2- import { SignalWatcher } from '@lit-labs/signals' ;
2+ import { signal , SignalWatcher } from '@lit-labs/signals' ;
33import type { TemplateResult } from 'lit' ;
44import { css , html , LitElement , nothing } from 'lit' ;
55import { customElement , state } from 'lit/decorators.js' ;
66import type { LaunchpadCommandArgs } from '../../../../../plus/launchpad/launchpad' ;
77import { createCommandLink } from '../../../../../system/commands' ;
88import { pluralize } from '../../../../../system/string' ;
99import type { GetLaunchpadSummaryResponse , State } from '../../../../home/protocol' ;
10- import { GetLaunchpadSummary } from '../../../../home/protocol' ;
10+ import { DidChangeLaunchpad , GetLaunchpadSummary } from '../../../../home/protocol' ;
1111import { stateContext } from '../../../home/context' ;
1212import { AsyncComputedState } from '../../../shared/components/signal-utils' ;
1313import { ipcContext } from '../../../shared/context' ;
@@ -102,7 +102,9 @@ export class GlLaunchpad extends SignalWatcher(LitElement) {
102102
103103 @consume ( { context : ipcContext } )
104104 private _ipc ! : HostIpc ;
105- private _disposable : Disposable | undefined ;
105+ private _disposable : Disposable [ ] = [ ] ;
106+
107+ private _summary = signal < GetLaunchpadSummaryResponse | undefined > ( undefined ) ;
106108
107109 private _summaryState = new AsyncComputedState < LaunchpadSummary > ( async _abortSignal => {
108110 const rsp = await this . _ipc . sendRequest ( GetLaunchpadSummary , { } ) ;
@@ -120,18 +122,28 @@ export class GlLaunchpad extends SignalWatcher(LitElement) {
120122 override connectedCallback ( ) {
121123 super . connectedCallback ( ) ;
122124
125+ this . _disposable . push (
126+ this . _ipc . onReceiveMessage ( msg => {
127+ switch ( true ) {
128+ case DidChangeLaunchpad . is ( msg ) :
129+ this . _summaryState . run ( true ) ;
130+ break ;
131+ }
132+ } ) ,
133+ ) ;
134+
123135 this . _summaryState . run ( ) ;
124136 }
125137
126138 override disconnectedCallback ( ) {
127139 super . disconnectedCallback ( ) ;
128140
129- this . _disposable ?. dispose ( ) ;
141+ this . _disposable . forEach ( d => d . dispose ( ) ) ;
130142 }
131143
132144 override render ( ) {
133145 return html `
134- < gl-section >
146+ < gl-section ?loading = ${ this . _summaryState . computed . status === 'pending' } >
135147 < span slot ="heading "> GitLens Launchpad</ span >
136148 < div class ="summary "> ${ this . renderSummaryResult ( ) } </ div >
137149 < button-container gap ="wide ">
0 commit comments