void _serviceWorker?.register();
}
-export function updateLastNotificationTime(timestamp: number): void {
- _serviceWorker?.updateLastNotificationTime(timestamp);
+export function updateLastNotificationTime(timestamp?: number): void {
+ _serviceWorker?.updateLastNotificationTime(timestamp ?? Math.round(Date.now() / 1000));
}
import { registerProvider } from "../Manager";
import * as Language from "../../../../Language";
import { enableNotifications } from "../../../../Notification/Handler";
-import { registerServiceWorker } from "../../../../Notification/ServiceWorker";
+import { registerServiceWorker, updateLastNotificationTime } from "../../../../Notification/ServiceWorker";
let originalFavicon = "";
function setFaviconCounter(counter: number): void {
const response = (await dboAction("markAsConfirmed", "wcf\\data\\user\\notification\\UserNotificationAction")
.objectIds([objectId])
.dispatch()) as ResponseMarkAsRead;
+ updateLastNotificationTime();
this.updateCounter(response.totalCount);
}
async markAllAsRead(): Promise<void> {
await dboAction("markAllAsConfirmed", "wcf\\data\\user\\notification\\UserNotificationAction").dispatch();
+ updateLastNotificationTime();
this.updateCounter(0);
}
void _serviceWorker?.register();
}
function updateLastNotificationTime(timestamp) {
- _serviceWorker?.updateLastNotificationTime(timestamp);
+ _serviceWorker?.updateLastNotificationTime(timestamp ?? Math.round(Date.now() / 1000));
}
});
const response = (await (0, Ajax_1.dboAction)("markAsConfirmed", "wcf\\data\\user\\notification\\UserNotificationAction")
.objectIds([objectId])
.dispatch());
+ (0, ServiceWorker_1.updateLastNotificationTime)();
this.updateCounter(response.totalCount);
}
async markAllAsRead() {
await (0, Ajax_1.dboAction)("markAllAsConfirmed", "wcf\\data\\user\\notification\\UserNotificationAction").dispatch();
+ (0, ServiceWorker_1.updateLastNotificationTime)();
this.updateCounter(0);
}
updateCounter(count) {
const storedTimestamp = getRequest.result;
// Check if the new timestamp is greater than the stored timestamp
- if (storedTimestamp === undefined || newTimestamp > storedTimestamp) {
+ if (storedTimestamp === undefined || timestamp > storedTimestamp) {
store.put(timestamp, 'lastNotification');
}
};