@@ -9,13 +9,13 @@ import { Settings } from "../../settings";
99import { instrumentOperation , sendInfo } from "vscode-extension-telemetry-wrapper" ;
1010
1111const KEY_PREFIX = 'javaupgrade.notificationManager' ;
12- const SESSION_COUNT_KEY = `${ KEY_PREFIX } .sessionCount ` ;
12+ const NEXT_SHOW_TS_KEY = `${ KEY_PREFIX } .nextShowTs ` ;
1313
1414const BUTTON_TEXT_UPGRADE = "Upgrade Now" ;
1515const BUTTON_TEXT_NOT_NOW = "Not Now" ;
16- const BUTTON_TEXT_DONT_SHOW_AGAIN = "Don't Show Again" ;
1716
18- const SESSION_COUNT_BEFORE_NOTIFICATION_RESHOW = 3 ;
17+ const SECONDS_IN_A_DAY = 24 * 60 * 60 ;
18+ const SECONDS_COUNT_BEFORE_NOTIFICATION_RESHOW = 10 * SECONDS_IN_A_DAY ;
1919
2020class NotificationManager implements IUpgradeIssuesRenderer {
2121 private hasShown = false ;
@@ -39,7 +39,7 @@ class NotificationManager implements IUpgradeIssuesRenderer {
3939 }
4040 this . hasShown = true ;
4141
42- this . setSessionCount ( ( this . getSessionCount ( ) ?? 0 ) + 1 ) ;
42+ this . setNextShowTs ( ( Number ( new Date ( ) ) / 1000 ) + SECONDS_COUNT_BEFORE_NOTIFICATION_RESHOW ) ;
4343
4444 if ( ! this . shouldShow ( ) ) {
4545 return ;
@@ -50,8 +50,7 @@ class NotificationManager implements IUpgradeIssuesRenderer {
5050 const selection = await window . showInformationMessage (
5151 notificationMessage ,
5252 BUTTON_TEXT_UPGRADE ,
53- BUTTON_TEXT_NOT_NOW ,
54- BUTTON_TEXT_DONT_SHOW_AGAIN ) ;
53+ BUTTON_TEXT_NOT_NOW ) ;
5554 sendInfo ( operationId , {
5655 operationName : "java.dependency.upgradeNotification.runUpgrade" ,
5756 choice : selection ?? "" ,
@@ -63,11 +62,7 @@ class NotificationManager implements IUpgradeIssuesRenderer {
6362 break ;
6463 }
6564 case BUTTON_TEXT_NOT_NOW : {
66- this . setSessionCount ( - 1 * SESSION_COUNT_BEFORE_NOTIFICATION_RESHOW ) ;
67- break ;
68- }
69- case BUTTON_TEXT_DONT_SHOW_AGAIN : {
70- Settings . disableWorkspaceDependencyCheckup ( ) ;
65+ this . setNextShowTs ( - 1 * SECONDS_COUNT_BEFORE_NOTIFICATION_RESHOW ) ;
7166 break ;
7267 }
7368 }
@@ -77,15 +72,15 @@ class NotificationManager implements IUpgradeIssuesRenderer {
7772
7873 private shouldShow ( ) {
7974 return Settings . getEnableDependencyCheckup ( )
80- && ( ( this . getSessionCount ( ) ?? 0 ) >= 0 ) ;
75+ && ( ( this . getNextShowTs ( ) ?? 0 ) <= ( Number ( new Date ( ) ) / 1000 ) ) ;
8176 }
8277
83- private getSessionCount ( ) {
84- return this . context ?. globalState . get < number > ( SESSION_COUNT_KEY ) ;
78+ private getNextShowTs ( ) {
79+ return this . context ?. globalState . get < number > ( NEXT_SHOW_TS_KEY ) ;
8580 }
8681
87- private setSessionCount ( num : number ) {
88- return this . context ?. globalState . update ( SESSION_COUNT_KEY , num ) ;
82+ private setNextShowTs ( num : number ) {
83+ return this . context ?. globalState . update ( NEXT_SHOW_TS_KEY , num ) ;
8984 }
9085}
9186
0 commit comments