1+ import type { ConfigurationChangeEvent } from 'vscode' ;
12import { Disposable , workspace } from 'vscode' ;
23import { getAvatarUriFromGravatarEmail } from '../../avatars' ;
34import type { ContextKeys } from '../../constants.context' ;
@@ -14,6 +15,7 @@ import { getLaunchpadSummary } from '../../plus/launchpad/utils';
1415import { map } from '../../system/iterable' ;
1516import { getSettledValue } from '../../system/promise' ;
1617import { registerCommand } from '../../system/vscode/command' ;
18+ import { configuration } from '../../system/vscode/configuration' ;
1719import { getContext , onDidChangeContext } from '../../system/vscode/context' ;
1820import type { IpcMessage } from '../protocol' ;
1921import type { WebviewHost , WebviewProvider , WebviewShowingArgs } from '../webviewProvider' ;
@@ -30,6 +32,7 @@ import {
3032 CollapseSectionCommand ,
3133 DidChangeIntegrationsConnections ,
3234 DidChangeOrgSettings ,
35+ DidChangePreviewEnabled ,
3336 DidChangeRepositories ,
3437 DidChangeSubscription ,
3538 DidChangeWalkthroughProgress ,
@@ -63,6 +66,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
6366 onDidChangeContext ( this . onContextChanged , this ) ,
6467 this . container . integrations . onDidChangeConnectionState ( this . onChangeConnectionState , this ) ,
6568 this . container . walkthrough . onProgressChanged ( this . onWalkthroughChanged , this ) ,
69+ configuration . onDidChange ( this . onDidChangeConfig , this ) ,
6670 ) ;
6771 }
6872
@@ -105,6 +109,12 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
105109 this . notifyDidChangeProgress ( ) ;
106110 }
107111
112+ private onDidChangeConfig ( e ?: ConfigurationChangeEvent ) {
113+ if ( configuration . changed ( e , 'home.preview.enabled' ) ) {
114+ this . notifyDidChangeConfig ( ) ;
115+ }
116+ }
117+
108118 registerCommands ( ) : Disposable [ ] {
109119 return [
110120 registerCommand ( `${ this . host . id } .refresh` , ( ) => this . host . refresh ( true ) , this ) ,
@@ -233,9 +243,14 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
233243 progress : this . container . walkthrough . progress ,
234244 } ,
235245 showWalkthroughProgress : ! this . getWalkthroughDismissed ( ) ,
246+ previewEnabled : this . getPreviewEnabled ( ) ,
236247 } ;
237248 }
238249
250+ private getPreviewEnabled ( ) {
251+ return configuration . get ( 'home.preview.enabled' ) ?? false ;
252+ }
253+
239254 private getRepositoriesState ( ) : DidChangeRepositoriesParams {
240255 return {
241256 count : this . container . git . repositoryCount ,
@@ -287,6 +302,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
287302 } ) ;
288303 }
289304
305+ private notifyDidChangeConfig ( ) {
306+ void this . host . notify ( DidChangePreviewEnabled , this . getPreviewEnabled ( ) ) ;
307+ }
308+
290309 private notifyDidChangeOnboardingIntegration ( ) {
291310 // force rechecking
292311 const isConnected = this . isAnyIntegrationConnected ( true ) ;
0 commit comments