1
1
import { consume } from '@lit/context' ;
2
- import { SignalWatcher } from '@lit-labs/signals' ;
2
+ import { signal , SignalWatcher } from '@lit-labs/signals' ;
3
3
import type { TemplateResult } from 'lit' ;
4
4
import { css , html , LitElement , nothing } from 'lit' ;
5
5
import { customElement , state } from 'lit/decorators.js' ;
6
6
import type { LaunchpadCommandArgs } from '../../../../../plus/launchpad/launchpad' ;
7
7
import { createCommandLink } from '../../../../../system/commands' ;
8
8
import { pluralize } from '../../../../../system/string' ;
9
9
import type { GetLaunchpadSummaryResponse , State } from '../../../../home/protocol' ;
10
- import { GetLaunchpadSummary } from '../../../../home/protocol' ;
10
+ import { DidChangeLaunchpad , GetLaunchpadSummary } from '../../../../home/protocol' ;
11
11
import { stateContext } from '../../../home/context' ;
12
12
import { AsyncComputedState } from '../../../shared/components/signal-utils' ;
13
13
import { ipcContext } from '../../../shared/context' ;
@@ -102,7 +102,9 @@ export class GlLaunchpad extends SignalWatcher(LitElement) {
102
102
103
103
@consume ( { context : ipcContext } )
104
104
private _ipc ! : HostIpc ;
105
- private _disposable : Disposable | undefined ;
105
+ private _disposable : Disposable [ ] = [ ] ;
106
+
107
+ private _summary = signal < GetLaunchpadSummaryResponse | undefined > ( undefined ) ;
106
108
107
109
private _summaryState = new AsyncComputedState < LaunchpadSummary > ( async _abortSignal => {
108
110
const rsp = await this . _ipc . sendRequest ( GetLaunchpadSummary , { } ) ;
@@ -120,18 +122,28 @@ export class GlLaunchpad extends SignalWatcher(LitElement) {
120
122
override connectedCallback ( ) {
121
123
super . connectedCallback ( ) ;
122
124
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
+
123
135
this . _summaryState . run ( ) ;
124
136
}
125
137
126
138
override disconnectedCallback ( ) {
127
139
super . disconnectedCallback ( ) ;
128
140
129
- this . _disposable ?. dispose ( ) ;
141
+ this . _disposable . forEach ( d => d . dispose ( ) ) ;
130
142
}
131
143
132
144
override render ( ) {
133
145
return html `
134
- < gl-section >
146
+ < gl-section ?loading = ${ this . _summaryState . computed . status === 'pending' } >
135
147
< span slot ="heading "> GitLens Launchpad</ span >
136
148
< div class ="summary "> ${ this . renderSummaryResult ( ) } </ div >
137
149
< button-container gap ="wide ">
0 commit comments