Skip to content

Commit ed83aca

Browse files
code clean up
1 parent b5b7c4c commit ed83aca

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

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

+41-38
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ import { nls } from '@theia/core/lib/common';
66
import { WindowService } from '@theia/core/lib/browser/window/window-service';
77
import { ArduinoPreferences } from '../arduino-preferences';
88

9-
export type Survey = {
10-
url: URL;
11-
id: string;
12-
};
13-
149
const SURVEY_MESSAGE = nls.localize(
1510
'arduino/survey/surveyMessage',
1611
'Please help us improve by answering this super short survey. We value our community and would like to get to know our supporters a little better.'
1712
);
1813
const DO_NOT_SHOW_AGAIN = nls.localize(
1914
'arduino/survey/dismissSurvey',
20-
'DONT SHOW ANYMORE'
15+
"DON'T SHOW ANYMORE"
2116
);
2217
const GO_TO_SURVEY = nls.localize(
2318
'arduino/survey/answerSurvey',
@@ -30,45 +25,53 @@ const surveyId = '17887b40-e1f0-4bd6-b9f0-a37f229ccd8b';
3025
@injectable()
3126
export class SurveyNotification implements FrontendApplicationContribution {
3227
@inject(MessageService)
33-
protected readonly messageService: MessageService;
28+
private readonly messageService: MessageService;
3429

3530
@inject(LocalStorageService)
36-
protected readonly localStorageService: LocalStorageService;
31+
private readonly localStorageService: LocalStorageService;
3732

3833
@inject(WindowService)
39-
protected readonly windowService: WindowService;
34+
private readonly windowService: WindowService;
4035

4136
@inject(ArduinoPreferences)
42-
protected readonly arduinoPreferences: ArduinoPreferences;
37+
private readonly arduinoPreferences: ArduinoPreferences;
4338

44-
async onStart(): Promise<void> {
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-
}
39+
onStart(): void {
40+
this.arduinoPreferences.ready.then(() => {
41+
if (this.arduinoPreferences.get('arduino.survey.notification')) {
42+
this.localStorageService
43+
.getData(this.surveyKey(surveyId))
44+
.then((surveyAnswered) => {
45+
if (surveyAnswered !== undefined) {
46+
return;
47+
}
48+
return this.messageService.info(
49+
SURVEY_MESSAGE,
50+
DO_NOT_SHOW_AGAIN,
51+
GO_TO_SURVEY
52+
);
53+
})
54+
.then((answer) => {
55+
switch (answer) {
56+
case GO_TO_SURVEY:
57+
this.windowService.openNewWindow(SURVEY_BASE_URL + surveyId, {
58+
external: true,
59+
});
60+
this.localStorageService.setData(
61+
this.surveyKey(surveyId),
62+
true
63+
);
64+
break;
65+
case DO_NOT_SHOW_AGAIN:
66+
this.localStorageService.setData(
67+
this.surveyKey(surveyId),
68+
false
69+
);
70+
break;
71+
}
72+
});
73+
}
74+
});
7275
}
7376

7477
private surveyKey(id: string): string {

0 commit comments

Comments
 (0)