Skip to content

Commit ab3acda

Browse files
add setting to disable surveys in advanced preferences
1 parent f215547 commit ab3acda

File tree

3 files changed

+41
-25
lines changed

3 files changed

+41
-25
lines changed

arduino-ide-extension/src/browser/arduino-preferences.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ export const ArduinoConfigSchema: PreferenceSchema = {
174174
),
175175
default: 'https://auth.arduino.cc/login#/register',
176176
},
177+
'arduino.survey.notification': {
178+
type: 'boolean',
179+
description: nls.localize(
180+
'arduino/preferences/survey.notification',
181+
'True if users should be notified if a survey is available. True by default.'
182+
),
183+
default: true,
184+
},
177185
},
178186
};
179187

@@ -198,6 +206,7 @@ export interface ArduinoConfiguration {
198206
'arduino.auth.domain': string;
199207
'arduino.auth.audience': string;
200208
'arduino.auth.registerUri': string;
209+
'arduino.survey.notification': boolean;
201210
}
202211

203212
export const ArduinoPreferences = Symbol('ArduinoPreferences');

arduino-ide-extension/src/browser/contributions/survey-notification.ts

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { inject, injectable } from '@theia/core/shared/inversify';
44
import { LocalStorageService } from '@theia/core/lib/browser';
55
import { nls } from '@theia/core/lib/common';
66
import { WindowService } from '@theia/core/lib/browser/window/window-service';
7+
import { ArduinoPreferences } from '../arduino-preferences';
78

89
export type Survey = {
910
url: URL;
@@ -37,32 +38,37 @@ export class SurveyNotification implements FrontendApplicationContribution {
3738
@inject(WindowService)
3839
protected readonly windowService: WindowService;
3940

41+
@inject(ArduinoPreferences)
42+
protected readonly arduinoPreferences: ArduinoPreferences;
43+
4044
async onStart(): Promise<void> {
41-
this.localStorageService
42-
.getData(this.surveyKey(surveyId), undefined)
43-
.then((surveyAnswered) => {
44-
if (surveyAnswered !== undefined) {
45-
return;
46-
}
47-
return this.messageService.info(
48-
SURVEY_MESSAGE,
49-
DO_NOT_SHOW_AGAIN,
50-
GO_TO_SURVEY
51-
);
52-
})
53-
.then((answer) => {
54-
switch (answer) {
55-
case GO_TO_SURVEY:
56-
this.windowService.openNewWindow(SURVEY_BASE_URL + surveyId, {
57-
external: true,
58-
});
59-
this.localStorageService.setData(this.surveyKey(surveyId), true);
60-
break;
61-
case DO_NOT_SHOW_AGAIN:
62-
this.localStorageService.setData(this.surveyKey(surveyId), false);
63-
break;
64-
}
65-
});
45+
if (this.arduinoPreferences.get('arduino.survey.notification')) {
46+
this.localStorageService
47+
.getData(this.surveyKey(surveyId), undefined)
48+
.then((surveyAnswered) => {
49+
if (surveyAnswered !== undefined) {
50+
return;
51+
}
52+
return this.messageService.info(
53+
SURVEY_MESSAGE,
54+
DO_NOT_SHOW_AGAIN,
55+
GO_TO_SURVEY
56+
);
57+
})
58+
.then((answer) => {
59+
switch (answer) {
60+
case GO_TO_SURVEY:
61+
this.windowService.openNewWindow(SURVEY_BASE_URL + surveyId, {
62+
external: true,
63+
});
64+
this.localStorageService.setData(this.surveyKey(surveyId), true);
65+
break;
66+
case DO_NOT_SHOW_AGAIN:
67+
this.localStorageService.setData(this.surveyKey(surveyId), false);
68+
break;
69+
}
70+
});
71+
}
6672
}
6773

6874
private surveyKey(id: string): string {

i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
"showVerbose": "Show verbose output during",
257257
"sketchbook.location": "Sketchbook location",
258258
"sketchbook.showAllFiles": "True to show all sketch files inside the sketch. It is false by default.",
259+
"survey.notification": "True if users should be notified if a survey is available. True by default.",
259260
"unofficialBoardSupport": "Click for a list of unofficial board support URLs",
260261
"upload": "upload",
261262
"upload.verbose": "True for verbose upload output. False by default.",

0 commit comments

Comments
 (0)