From 87d100c41e4d1bb399dc5f9f46ed896fe8801815 Mon Sep 17 00:00:00 2001 From: Macbook Date: Thu, 4 Jun 2026 14:03:52 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EC=A0=84=EC=B2=B4?= =?UTF-8?q?=EB=8B=AB=EA=B8=B0=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/contexts/TradeNotificationContext.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/contexts/TradeNotificationContext.tsx b/frontend/src/contexts/TradeNotificationContext.tsx index 2ea4948..940e337 100644 --- a/frontend/src/contexts/TradeNotificationContext.tsx +++ b/frontend/src/contexts/TradeNotificationContext.tsx @@ -233,6 +233,17 @@ export const TradeNotificationProvider: React.FC = ({ useEffect(() => { if (!settingsLoaded) return; + /** + * 앱 설정이 DB 에서 로드 완료된 시점에 readIds 를 즉시 동기화한다. + * STOMP 가 앱 시작 직후 구독 시 readIds 가 아직 빈 상태여서 이미 닫은 + * 알림이 다시 팝업으로 뜨는 타이밍 버그를 방지한다. + */ + const dbRead = loadReadIds(); + if (dbRead.size > 0) { + const merged = new Set([...readIdsRef.current, ...dbRead]); + readIdsRef.current = merged; + setReadIds(merged); + } setToastNotifications([]); void refreshHistory({ serverOnly: true, rawServerList: true }); }, [refreshHistory, settingsLoaded, settingsSessionKey]); @@ -262,7 +273,9 @@ export const TradeNotificationProvider: React.FC = ({ * STOMP 재연결 시 동일 신호가 재수신되거나 20 초 폴링에서 새로 발견되어도 * 사용자가 명시적으로 닫은 알림은 다시 열리지 않는다. */ - const alreadyRead = readIdsRef.current.has(id); + // readIdsRef.current (인메모리) 와 DB 캐시(loadReadIds) 모두 확인. + // 앱 시작 초기 설정 로드 전 STOMP 신호 수신 시에도 읽음 상태를 올바르게 판단한다. + const alreadyRead = readIdsRef.current.has(id) || loadReadIds().has(id); setAllNotifications(prev => { const existing = prev.find(n => n.id === id);