Review expense history page

This commit is contained in:
gpt-engineer-app[bot]
2025-03-18 04:12:54 +00:00
parent a0074c2d1d
commit 2b8069a150
5 changed files with 75 additions and 135 deletions

View File

@@ -25,6 +25,18 @@ export const useDeleteTransactionCore = (
pendingDeletionRef.current = new Set<string>();
}
// 이미 삭제 중인지 확인
if (pendingDeletionRef.current.has(id)) {
console.log('이미 삭제 중인 트랜잭션:', id);
toast({
title: "처리 중",
description: "이전 삭제 작업이 진행 중입니다.",
duration: 1500
});
resolve(false);
return;
}
// 트랜잭션이 존재하는지 확인
const transactionToDelete = transactions.find(t => t.id === id);
if (!transactionToDelete) {
@@ -42,35 +54,31 @@ export const useDeleteTransactionCore = (
// UI 업데이트 - 동기식 처리
setTransactions(updatedTransactions);
// 삭제 성공 토스트
toast({
title: "삭제 완료",
description: "지출 항목이 삭제되었습니다.",
duration: 2000
});
// UI 업데이트 완료 후 즉시 성공 반환 (사용자 경험 개선)
resolve(true);
// 백그라운드에서 스토리지 작업 처리 (setTimeout 사용해 메인 스레드 차단 방지)
// 백그라운드에서 스토리지 작업 처리
setTimeout(() => {
try {
// 스토리지 처리
// 스토리지 처리 - 간소화된 함수 호출
handleDeleteStorage(
false, // 취소 상태 없음
updatedTransactions,
id,
user,
transactionToDelete,
pendingDeletionRef
);
} catch (storageError) {
console.error('스토리지 작업 오류:', storageError);
} finally {
// 작업 완료 후 보류 중인 삭제 목록에서 제거
if (pendingDeletionRef.current) {
pendingDeletionRef.current.delete(id);
}
// 트랜잭션 삭제 완료 이벤트 발생
try {
window.dispatchEvent(new Event('transactionDeleted'));
} catch (e) {
console.warn('이벤트 발생 오류:', e);
}
}
}, 50);