fix: retain server notifications when local alerts arrive

This commit is contained in:
2026-09-06 14:56:21 +03:00
parent 120657758c
commit 2353170c40
4 changed files with 36 additions and 5 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
import {validateReminderPreferences,quietNow} from '../services/reminderPreferences';
import {validateTeam} from '../services/teamData';
import {savedFilterCriteria} from '../services/savedFilterCriteria';
import {mergeServerNotifications,acknowledgeNotifications} from '../services/notifications';
import {mergeServerNotifications,acknowledgeNotifications,addLocalNotification} from '../services/notifications';
import { searchTender } from '../services/searchTender';
import { normalizeTenderSearch, matchingItemResults } from '../services/tenderSearch';
import React, {createContext, useContext, useState, useEffect, useMemo, useRef } from 'react';
@@ -579,7 +579,7 @@ export const AppProvider = ({ children }) => {
// Gerçek bildirim: listeye ekler; sessiz saat dışında ve push açıksa tarayıcı
// bildirimi (Notification API) da gösterir.
const notify = (title, text) => {
setNotifications((prev) => [{ id: 'n-' + Date.now(), title, text, time: 'az önce', read: false }, ...prev].slice(0, 30));
setNotifications(prev=>addLocalNotification(prev,title,text));
pushNotification(title,text);
};
const pushNotification=(title,text)=>{
@@ -605,7 +605,7 @@ export const AppProvider = ({ children }) => {
const fresh=checked.filter(row=>!row.read&&!seenServerNotifications.current.has(row.id));
checked.forEach(row=>seenServerNotifications.current.add(row.id));
fresh.slice(0,5).forEach(row=>pushNotification(row.title,row.text));
setNotifications(current=>[...checked,...current.filter(row=>!row.serverId)].slice(0,80));
setNotifications(current=>mergeServerNotifications(current,rows));
}catch(error){if(getToken()===session&&version===notificationVersion.current)setNotificationError(error.message);}
};
const markNotificationsRead=async()=>{