@@ -16,6 +16,7 @@ import * as PersistentState from './common/persistentState';
1616import { parseRepositoryRemotes } from './common/remote' ;
1717import { Resource } from './common/resources' ;
1818import { BRANCH_PUBLISH , EXPERIMENTAL_CHAT , EXPERIMENTAL_NOTIFICATIONS , FILE_LIST_LAYOUT , GIT , OPEN_DIFF_ON_CLICK , PR_SETTINGS_NAMESPACE , SHOW_INLINE_OPEN_FILE_ACTION } from './common/settingKeys' ;
19+ import { initBasedOnSettingChange } from './common/settingsUtils' ;
1920import { TemporaryState } from './common/temporaryState' ;
2021import { Schemes , handler as uriHandler } from './common/uri' ;
2122import { EXTENSION_ID , FOCUS_REVIEW_MODE } from './constants' ;
@@ -222,10 +223,15 @@ async function init(
222223 context . subscriptions . push ( issuesFeatures ) ;
223224 await issuesFeatures . initialize ( ) ;
224225
225- const notificationsViewEnabled = vscode . workspace . getConfiguration ( PR_SETTINGS_NAMESPACE ) . get < boolean > ( EXPERIMENTAL_NOTIFICATIONS , false ) ;
226- if ( notificationsViewEnabled ) {
226+ const notificationsViewEnabled = ( ) => vscode . workspace . getConfiguration ( PR_SETTINGS_NAMESPACE ) . get < boolean > ( EXPERIMENTAL_NOTIFICATIONS , false ) ;
227+ const initNotifications = ( ) => {
227228 const notificationsFeatures = new NotificationsFeatureRegister ( credentialStore , reposManager , telemetry ) ;
228229 context . subscriptions . push ( notificationsFeatures ) ;
230+ } ;
231+ if ( notificationsViewEnabled ( ) ) {
232+ initNotifications ( ) ;
233+ } else {
234+ initBasedOnSettingChange ( PR_SETTINGS_NAMESPACE , EXPERIMENTAL_NOTIFICATIONS , notificationsViewEnabled , initNotifications , context . subscriptions ) ;
229235 }
230236
231237 context . subscriptions . push ( new GitLensIntegration ( ) ) ;
@@ -255,15 +261,7 @@ function initChat(context: vscode.ExtensionContext, credentialStore: CredentialS
255261 if ( chatEnabled ( ) ) {
256262 createParticipant ( ) ;
257263 } else {
258- const disposable = vscode . workspace . onDidChangeConfiguration ( e => {
259- if ( e . affectsConfiguration ( `${ PR_SETTINGS_NAMESPACE } .${ EXPERIMENTAL_CHAT } ` ) ) {
260- if ( chatEnabled ( ) ) {
261- disposable . dispose ( ) ;
262- createParticipant ( ) ;
263- }
264- }
265- } ) ;
266- context . subscriptions . push ( disposable ) ;
264+ initBasedOnSettingChange ( PR_SETTINGS_NAMESPACE , EXPERIMENTAL_CHAT , chatEnabled , createParticipant , context . subscriptions ) ;
267265 }
268266}
269267
0 commit comments