bugfixing

This commit is contained in:
MuslemRahimi 2025-02-02 11:52:46 +01:00
parent 04364ec178
commit 31c7bfeb7b
2 changed files with 11 additions and 14 deletions

View File

@ -19,11 +19,9 @@ onmessage = async (event: MessageEvent) => {
let output = {} let output = {}
try { try {
const [notificationList] = await Promise?.all([loadNotifications()]); const [notificationList] = await Promise?.all([loadNotifications()]);
const numberOfUnreadNotification = notificationList?.filter( const numberOfUnreadNotification = notificationList?.length
(item?) => !item?.readed,
);
const hasUnreadElement = const hasUnreadElement =
numberOfUnreadNotification?.length !== 0 ? true : false; numberOfUnreadNotification > 0 ? true : false;
output = { output = {
notificationList, notificationList,
hasUnreadElement, hasUnreadElement,

View File

@ -91,7 +91,7 @@
const output = event.data?.output; const output = event.data?.output;
notificationList = output?.notificationList; notificationList = output?.notificationList;
hasUnreadElement = output?.hasUnreadElement; hasUnreadElement = output?.hasUnreadElement;
numberOfUnreadNotification.set(output?.numberOfUnreadNotification?.length); numberOfUnreadNotification.set(output?.numberOfUnreadNotification);
//pushNotification() //pushNotification()
}; };
@ -100,8 +100,8 @@
const permissionGranted = await requestNotificationPermission(); const permissionGranted = await requestNotificationPermission();
if (permissionGranted) { if (permissionGranted) {
sendNotification("Stocknear", { sendNotification("Price Alert for ZBRA", {
body: "Celestica shares are trading higher following better-than-expected Q4 financial results and Q1 guidance issued above estimates.", body: `📈 The price of 12 is above your target of 23.`,
iconSize: 12, iconSize: 12,
url: "/notifications", url: "/notifications",
}); });
@ -150,20 +150,19 @@
async function fallbackWorker() { async function fallbackWorker() {
// Implement fallback logic here, e.g., using timers or other techniques // Implement fallback logic here, e.g., using timers or other techniques
console.log("Fallback worker activated"); console.log("Fallback worker activated");
const postData = { readed: false };
const response = await fetch("/api/get-notifications", { const response = await fetch("/api/get-notifications", {
method: "GET", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify(postData),
}); });
notificationList = await response.json(); notificationList = await response.json();
const numberOfUnreadNotification = notificationList.filter( const unreadNotifications = notificationList?.length; //notificationList.filter((item?) => !item?.readed,);
(item?) => !item?.readed, hasUnreadElement = unreadNotifications > 0 ? true : false;
); numberOfUnreadNotification.set(unreadNotifications);
hasUnreadElement = numberOfUnreadNotification?.length !== 0 ? true : false;
numberOfUnreadNotification.set(numberOfUnreadNotification?.length);
} }
let Cookie; let Cookie;