알림팝업 전체닫기 오류 수정
This commit is contained in:
@@ -10,6 +10,7 @@ import React, {
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import type { TradeSignalInfo } from '../components/TradeAlertModal';
|
||||
@@ -121,6 +122,8 @@ export const TradeNotificationProvider: React.FC<ProviderProps> = ({
|
||||
const alertSoundId = normalizeTradeAlertSoundId(soundId) as TradeAlertSoundId;
|
||||
const [readIds, setReadIds] = useState<Set<string>>(() => loadReadIds());
|
||||
const [toastNotifications, setToastNotifications] = useState<TradeNotificationItem[]>([]);
|
||||
const toastNotificationsRef = useRef(toastNotifications);
|
||||
toastNotificationsRef.current = toastNotifications;
|
||||
const [allNotifications, setAllNotifications] = useState<TradeNotificationItem[]>([]);
|
||||
const [detailSignal, setDetailSignal] = useState<TradeSignalInfo | null>(null);
|
||||
const [detailCentered, setDetailCentered] = useState(false);
|
||||
@@ -247,20 +250,10 @@ export const TradeNotificationProvider: React.FC<ProviderProps> = ({
|
||||
}, []);
|
||||
|
||||
const dismissAllToasts = useCallback(() => {
|
||||
setToastNotifications(prev => {
|
||||
const ids = prev.map(n => n.id);
|
||||
setReadIds(r => {
|
||||
const next = new Set(r);
|
||||
ids.forEach(i => next.add(i));
|
||||
saveReadIds(next);
|
||||
return next;
|
||||
});
|
||||
setAllNotifications(all =>
|
||||
all.map(n => (ids.includes(n.id) ? { ...n, isRead: true } : n)),
|
||||
);
|
||||
return [];
|
||||
});
|
||||
}, []);
|
||||
const ids = toastNotificationsRef.current.map(n => n.id);
|
||||
if (ids.length === 0) return;
|
||||
dismissToasts(ids);
|
||||
}, [dismissToasts]);
|
||||
|
||||
const markAllAsRead = useCallback(() => {
|
||||
setAllNotifications(prev => {
|
||||
|
||||
Reference in New Issue
Block a user