Skip to content

Commit 7666d1d

Browse files
committed
Simplify inactiveThreshold date math
1 parent cc554e6 commit 7666d1d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

glean/src/core/sessions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ export function isSessionInactive(sessionLengthInMinutes = 30): boolean {
1212
const lastActive = localStorage.getItem("glean_session_last_active");
1313
const lastActiveDate = new Date(Number(lastActive));
1414

15-
// Subtract the session length from the current date
16-
const inactiveThreshold = new Date(Date.now() - (60000 * sessionLengthInMinutes));
15+
// Subtract the session length from the current date.
16+
const inactiveThreshold = new Date();
17+
inactiveThreshold.setMinutes(inactiveThreshold.getMinutes() - sessionLengthInMinutes);
1718

1819
// If the inactiveThreshold is more recent than the lastActiveDate, then the
1920
// current session is expired.

0 commit comments

Comments
 (0)