Skip to content

Commit 430f7e8

Browse files
feat: update notification display UX
1 parent aea445f commit 430f7e8

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

src/settings.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ export class Settings {
5858
workspace.getConfiguration("java.dependency").update("packagePresentation", PackagePresentation.Hierarchical, false);
5959
}
6060

61-
public static disableWorkspaceDependencyCheckup() {
62-
return workspace.getConfiguration("java.dependency").update("enableDependencyCheckup", false, ConfigurationTarget.Workspace);
63-
}
64-
6561
public static switchNonJavaResourceFilter(enabled: boolean): void {
6662
workspace.getConfiguration("java.project.explorer").update(
6763
"showNonJavaResources",

src/upgrade/display/notificationManager.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import { Settings } from "../../settings";
99
import { instrumentOperation, sendInfo } from "vscode-extension-telemetry-wrapper";
1010

1111
const KEY_PREFIX = 'javaupgrade.notificationManager';
12-
const SESSION_COUNT_KEY = `${KEY_PREFIX}.sessionCount`;
12+
const NEXT_SHOW_TS_KEY = `${KEY_PREFIX}.nextShowTs`;
1313

1414
const BUTTON_TEXT_UPGRADE = "Upgrade Now";
1515
const 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

2020
class 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

Comments
 (0)