Skip to content

Commit 7da7cb8

Browse files
committed
Merge branch 'master' of github.com:isaacphysics/isaac-react-app into cs-related-questions
2 parents ed730ee + 95d81d2 commit 7da7cb8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/app/components/navigation/IsaacApp.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ export const IsaacApp = () => {
8989
}, []);
9090

9191
useEffect(() => {
92+
const dateNow = new Date();
9293
if (showNotification(user) && notifications && notifications.length > 0) {
9394
dispatch(openActiveModal(notificationModal(notifications[0])));
94-
persistence.save(KEY.LAST_NOTIFICATION_TIME, Date.now().toString())
95+
persistence.save(KEY.LAST_NOTIFICATION_TIME, dateNow.toString())
9596
}
9697
}, [notifications, user]);
9798

src/app/services/notificationChecker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import {KEY} from "./localStorage";
44

55

66
export function showNotification(user: RegisteredUserDTO | null) {
7-
if (user && user.registrationDate && (Date.now() - (Number(user.registrationDate)) > 14*24*60*60*1000)) {
8-
if (Date.now() - Number(persistence.load(KEY.LAST_NOTIFICATION_TIME)) > 24*60*60*1000) {
7+
const dateNow = new Date();
8+
const notificationTime = persistence.load(KEY.LAST_NOTIFICATION_TIME);
9+
if (user && user.registrationDate && (dateNow.getTime() - new Date(user.registrationDate).getTime()) > 14*24*60*60*1000) {
10+
if (dateNow.getTime() - (new Date(notificationTime || "0").getTime()) > 24*60*60*1000) {
911
return true
1012
}
1113
} else return false

0 commit comments

Comments
 (0)