Format dates for synchronization
Use ISO format for data synchronization and user-friendly format for display.
This commit is contained in:
@@ -43,6 +43,20 @@ export const useTransactionsEvents = (
|
||||
}, 200);
|
||||
};
|
||||
|
||||
// 트랜잭션 변경 이벤트 (통합 이벤트)
|
||||
const handleTransactionChange = (e: CustomEvent) => {
|
||||
console.log('트랜잭션 변경 이벤트 감지:', e.detail?.type);
|
||||
|
||||
// 처리 중 중복 호출 방지
|
||||
if (isProcessing) return;
|
||||
|
||||
isProcessing = true;
|
||||
setTimeout(() => {
|
||||
loadTransactions();
|
||||
isProcessing = false;
|
||||
}, 150);
|
||||
};
|
||||
|
||||
// 스토리지 이벤트
|
||||
const handleStorageEvent = (e: StorageEvent) => {
|
||||
if (e.key === 'transactions' || e.key === null) {
|
||||
@@ -76,6 +90,7 @@ export const useTransactionsEvents = (
|
||||
// 이벤트 리스너 등록
|
||||
window.addEventListener('transactionUpdated', handleTransactionUpdate);
|
||||
window.addEventListener('transactionDeleted', handleTransactionDelete);
|
||||
window.addEventListener('transactionChanged', handleTransactionChange as EventListener);
|
||||
window.addEventListener('storage', handleStorageEvent);
|
||||
window.addEventListener('focus', handleFocus);
|
||||
|
||||
@@ -89,6 +104,7 @@ export const useTransactionsEvents = (
|
||||
console.log('useTransactions - 이벤트 리스너 제거');
|
||||
window.removeEventListener('transactionUpdated', handleTransactionUpdate);
|
||||
window.removeEventListener('transactionDeleted', handleTransactionDelete);
|
||||
window.removeEventListener('transactionChanged', handleTransactionChange as EventListener);
|
||||
window.removeEventListener('storage', handleStorageEvent);
|
||||
window.removeEventListener('focus', handleFocus);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user