매매 시그널알림 화면 수정

This commit is contained in:
Macbook
2026-05-29 01:05:52 +09:00
parent e1ad1d626e
commit 19ae5f5fae
5 changed files with 130 additions and 58 deletions
@@ -57,6 +57,8 @@ interface TradeNotificationContextValue {
markAllAsRead: () => void;
/** 알림 목록에서 단건 삭제 */
deleteNotification: (id: string) => Promise<void>;
/** 지정 id 알림 일괄 삭제 (목록 선택 삭제) */
deleteNotifications: (ids: string[]) => Promise<void>;
/** 읽지 않은(미확인) 알림만 삭제 */
deleteUnreadNotifications: () => Promise<void>;
/** 알림 목록 전체 삭제 */
@@ -377,33 +379,33 @@ export const TradeNotificationProvider: React.FC<ProviderProps> = ({
?? toastNotificationsRef.current.find(n => n.id === id);
}, [allNotifications]);
const deleteNotification = useCallback(async (id: string) => {
const item = findNotificationById(id);
purgeNotifications([id]);
if (item?.dbId != null) {
try {
await deleteTradeSignal(item.dbId);
} catch (e) {
console.warn('[TradeNotification] 서버 삭제 실패:', e);
}
const deleteNotifications = useCallback(async (ids: string[]) => {
const unique = [...new Set(ids)].filter(Boolean);
if (unique.length === 0) return;
const dbIds: number[] = [];
for (const id of unique) {
const item = findNotificationById(id);
if (item?.dbId != null) dbIds.push(item.dbId);
}
}, [findNotificationById, purgeNotifications]);
const deleteUnreadNotifications = useCallback(async () => {
const snapshot = [...allNotifications];
const unread = snapshot.filter(n => !n.isRead);
if (unread.length === 0) return;
const ids = unread.map(n => n.id);
const dbIds = unread.map(n => n.dbId).filter((x): x is number => x != null);
purgeNotifications(ids);
purgeNotifications(unique);
if (dbIds.length > 0) {
try {
await deleteTradeSignalsBatch(dbIds);
} catch (e) {
console.warn('[TradeNotification] 미확인 일괄 삭제 실패:', e);
console.warn('[TradeNotification] 일괄 삭제 실패:', e);
}
}
}, [allNotifications, purgeNotifications]);
}, [findNotificationById, purgeNotifications]);
const deleteNotification = useCallback(async (id: string) => {
await deleteNotifications([id]);
}, [deleteNotifications]);
const deleteUnreadNotifications = useCallback(async () => {
const unread = allNotifications.filter(n => !n.isRead);
if (unread.length === 0) return;
await deleteNotifications(unread.map(n => n.id));
}, [allNotifications, deleteNotifications]);
const deleteAllNotifications = useCallback(async () => {
const ids = [
@@ -454,6 +456,7 @@ export const TradeNotificationProvider: React.FC<ProviderProps> = ({
markAsRead,
markAllAsRead,
deleteNotification,
deleteNotifications,
deleteUnreadNotifications,
deleteAllNotifications,
refreshHistory,