@@ -28,8 +28,17 @@ export const onDidSelectOrganization = selectOrganizationEvent.event;
28
28
const seenOrganizations = new Set < string > ( ) ;
29
29
const lastUpdated1ESPTSchema = new Map < string , Date > ( ) ;
30
30
31
+ export const DO_NOT_ASK_SIGN_IN_KEY = "DO_NOT_ASK_SIGN_IN_KEY" ;
32
+ export const DO_NOT_ASK_SELECT_ORG_KEY = "DO_NOT_ASK_SELECT_ORG_KEY" ;
33
+
31
34
let repoId1espt : string | undefined = undefined ;
32
35
36
+ export async function resetDoNotAskState ( context : vscode . ExtensionContext ) {
37
+ await context . globalState . update ( DO_NOT_ASK_SIGN_IN_KEY , undefined ) ;
38
+ await context . globalState . update ( DO_NOT_ASK_SELECT_ORG_KEY , undefined ) ;
39
+ logger . log ( "State is reset" ) ;
40
+ }
41
+
33
42
export async function locateSchemaFile (
34
43
context : vscode . ExtensionContext ,
35
44
workspaceFolder : vscode . WorkspaceFolder | undefined ) : Promise < string > {
@@ -105,6 +114,12 @@ async function autoDetectSchema(
105
114
// can't return until the sessions are also available.
106
115
// This only returns false if there is no login.
107
116
if ( ! ( await azureAccountApi . waitForSubscriptions ( ) ) ) {
117
+ const doNotAskAgainSignIn = context . globalState . get < boolean > ( DO_NOT_ASK_SIGN_IN_KEY ) ;
118
+ if ( doNotAskAgainSignIn ) {
119
+ logger . log ( `Not prompting for login - do not ask again was set` , 'SchemaDetection' ) ;
120
+ return undefined ;
121
+ }
122
+
108
123
logger . log ( `Waiting for login` , 'SchemaDetection' ) ;
109
124
110
125
try {
@@ -117,7 +132,7 @@ async function autoDetectSchema(
117
132
118
133
// Don't await this message so that we can return the fallback schema instead of blocking.
119
134
// We'll detect the login in extension.ts and then re-request the schema.
120
- void vscode . window . showInformationMessage ( Messages . signInForEnhancedIntelliSense , Messages . signInLabel )
135
+ void vscode . window . showInformationMessage ( Messages . signInForEnhancedIntelliSense , Messages . signInLabel , Messages . doNotAskAgain )
121
136
. then ( async action => {
122
137
if ( action === Messages . signInLabel ) {
123
138
await vscode . window . withProgress ( {
@@ -126,6 +141,8 @@ async function autoDetectSchema(
126
141
} , async ( ) => {
127
142
await vscode . commands . executeCommand ( "azure-account.login" ) ;
128
143
} ) ;
144
+ } else if ( action === Messages . doNotAskAgain ) {
145
+ await context . globalState . update ( DO_NOT_ASK_SIGN_IN_KEY , true ) ;
129
146
}
130
147
} ) ;
131
148
@@ -190,6 +207,12 @@ async function autoDetectSchema(
190
207
`Using cached information for ${ workspaceFolder . name } : ${ organizationName } , ${ session ?. tenantId } ` ,
191
208
'SchemaDetection' ) ;
192
209
} else {
210
+ const doNotAskAgainSelectOrg = context . globalState . get < boolean > ( DO_NOT_ASK_SELECT_ORG_KEY ) ;
211
+ if ( doNotAskAgainSelectOrg ) {
212
+ logger . log ( `Not prompting for organization - do not ask again was set` , 'SchemaDetection' ) ;
213
+ return ;
214
+ }
215
+
193
216
logger . log ( `Prompting for organization for ${ workspaceFolder . name } ` , 'SchemaDetection' ) ;
194
217
195
218
// Otherwise, we need to manually prompt.
@@ -199,7 +222,7 @@ async function autoDetectSchema(
199
222
// We'll detect when they choose the organization in extension.ts and then re-request the schema.
200
223
void vscode . window . showInformationMessage (
201
224
format ( Messages . selectOrganizationForEnhancedIntelliSense , workspaceFolder . name ) ,
202
- Messages . selectOrganizationLabel )
225
+ Messages . selectOrganizationLabel , Messages . doNotAskAgain )
203
226
. then ( async action => {
204
227
if ( action === Messages . selectOrganizationLabel ) {
205
228
// Lazily construct list of organizations so that we can immediately show the quick pick,
@@ -237,6 +260,8 @@ async function autoDetectSchema(
237
260
} ) ;
238
261
239
262
selectOrganizationEvent . fire ( workspaceFolder ) ;
263
+ } else if ( action === Messages . doNotAskAgain ) {
264
+ await context . globalState . update ( DO_NOT_ASK_SELECT_ORG_KEY , true ) ;
240
265
}
241
266
} ) ;
242
267
return undefined ;
0 commit comments