Fix transaction deletion issue

Addresses an issue where the application becomes unresponsive after deleting a transaction.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-17 23:41:03 +00:00
parent 196c071b53
commit ce12e99f6d
4 changed files with 116 additions and 39 deletions

View File

@@ -21,9 +21,12 @@ export const useDeleteTransactionCore = (
pendingDeletionRef.current = new Set<string>();
}
// 프로미스 객체와 취소 함수 참조를 위한 변수 선언
let promiseObj: Promise<boolean> & { cancel?: () => void };
// 기존 promise를 변수로 저장해서 참조 가능하게 함
const promiseObj = new Promise<boolean>((resolve, reject) => {
// 삭제 작업 취소 플래그 초기화
promiseObj = new Promise<boolean>((resolve, reject) => {
// 삭제 작업 취소 플래그 초기화 - 프로미스 내부에서 선언
let isCanceled = false;
try {
@@ -106,8 +109,8 @@ export const useDeleteTransactionCore = (
reject(error);
}
// cancel 함수에서 참조할 수 있도록 클로저로 isCanceled 변수 노출
(promiseObj as any).cancel = () => {
// cancel 함수를 프로미스 객체에 연결 (프로미스 내부에서)
promiseObj.cancel = () => {
isCanceled = true;
pendingDeletionRef.current?.delete(id);
console.log('트랜잭션 삭제 작업 취소 완료');