Skip to content

Commit 440e92e

Browse files
chore: merge getNowTs()
1 parent 430f7e8 commit 440e92e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/upgrade/display/notificationManager.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const BUTTON_TEXT_NOT_NOW = "Not Now";
1717
const SECONDS_IN_A_DAY = 24 * 60 * 60;
1818
const SECONDS_COUNT_BEFORE_NOTIFICATION_RESHOW = 10 * SECONDS_IN_A_DAY;
1919

20+
function getNowTs() {
21+
return Number(new Date()) / 1000;
22+
}
23+
2024
class NotificationManager implements IUpgradeIssuesRenderer {
2125
private hasShown = false;
2226
private context?: ExtensionContext;
@@ -39,8 +43,6 @@ class NotificationManager implements IUpgradeIssuesRenderer {
3943
}
4044
this.hasShown = true;
4145

42-
this.setNextShowTs((Number(new Date()) / 1000) + SECONDS_COUNT_BEFORE_NOTIFICATION_RESHOW);
43-
4446
if (!this.shouldShow()) {
4547
return;
4648
}
@@ -62,7 +64,7 @@ class NotificationManager implements IUpgradeIssuesRenderer {
6264
break;
6365
}
6466
case BUTTON_TEXT_NOT_NOW: {
65-
this.setNextShowTs(-1 * SECONDS_COUNT_BEFORE_NOTIFICATION_RESHOW);
67+
this.setNextShowTs(getNowTs() + SECONDS_COUNT_BEFORE_NOTIFICATION_RESHOW);
6668
break;
6769
}
6870
}
@@ -72,7 +74,7 @@ class NotificationManager implements IUpgradeIssuesRenderer {
7274

7375
private shouldShow() {
7476
return Settings.getEnableDependencyCheckup()
75-
&& ((this.getNextShowTs() ?? 0) <= (Number(new Date()) / 1000));
77+
&& ((this.getNextShowTs() ?? 0) <= getNowTs());
7678
}
7779

7880
private getNextShowTs() {

0 commit comments

Comments
 (0)