@@ -6,18 +6,13 @@ import { nls } from '@theia/core/lib/common';
6
6
import { WindowService } from '@theia/core/lib/browser/window/window-service' ;
7
7
import { ArduinoPreferences } from '../arduino-preferences' ;
8
8
9
- export type Survey = {
10
- url : URL ;
11
- id : string ;
12
- } ;
13
-
14
9
const SURVEY_MESSAGE = nls . localize (
15
10
'arduino/survey/surveyMessage' ,
16
11
'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.'
17
12
) ;
18
13
const DO_NOT_SHOW_AGAIN = nls . localize (
19
14
'arduino/survey/dismissSurvey' ,
20
- ' DON’ T SHOW ANYMORE'
15
+ " DON' T SHOW ANYMORE"
21
16
) ;
22
17
const GO_TO_SURVEY = nls . localize (
23
18
'arduino/survey/answerSurvey' ,
@@ -30,45 +25,53 @@ const surveyId = '17887b40-e1f0-4bd6-b9f0-a37f229ccd8b';
30
25
@injectable ( )
31
26
export class SurveyNotification implements FrontendApplicationContribution {
32
27
@inject ( MessageService )
33
- protected readonly messageService : MessageService ;
28
+ private readonly messageService : MessageService ;
34
29
35
30
@inject ( LocalStorageService )
36
- protected readonly localStorageService : LocalStorageService ;
31
+ private readonly localStorageService : LocalStorageService ;
37
32
38
33
@inject ( WindowService )
39
- protected readonly windowService : WindowService ;
34
+ private readonly windowService : WindowService ;
40
35
41
36
@inject ( ArduinoPreferences )
42
- protected readonly arduinoPreferences : ArduinoPreferences ;
37
+ private readonly arduinoPreferences : ArduinoPreferences ;
43
38
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
+ } ) ;
72
75
}
73
76
74
77
private surveyKey ( id : string ) : string {
0 commit comments