네트워크 알림 OFF 및 ts 오류 수정

This commit is contained in:
hansoo
2025-03-21 17:09:26 +09:00
parent 3d246176ad
commit b3cc189493
6 changed files with 30 additions and 155 deletions

View File

@@ -18,7 +18,8 @@ export const withRetry = async <T>(
maxRetries = MAX_RETRY_COUNT,
retryDelay = INITIAL_RETRY_DELAY,
onRetry = () => {},
shouldRetry = () => true
shouldRetry = () => true,
entityType
} = options;
let lastError: Error | unknown;

View File

@@ -32,4 +32,5 @@ export interface RetryOptions<T> {
retryDelay?: number;
onRetry?: (attempt: number, error: Error | unknown) => void;
shouldRetry?: (error: Error | unknown) => boolean;
entityType?: string; // 동기화 작업 유형 (예: '트랜잭션 업로드', '예산 다운로드' 등)
}

View File

@@ -1,3 +1,13 @@
/**
* 네트워크 유틸리티 모듈
*
* 이 파일은 하위 모듈로 리팩토링되었습니다.
* 기존 코드와의 호환성을 위해 새 모듈에서 모든 기능을 재내보냅니다.
*/
// 모든 네트워크 유틸리티 기능을 새 모듈에서 가져와 재내보내기
export * from './network';
/**
* 네트워크 상태 관리 및 오류 처리를 위한 유틸리티
*/
@@ -457,6 +467,7 @@ export const withRetry = async <T>(
retryDelay?: number;
onRetry?: (attempt: number, error: Error | unknown) => void;
shouldRetry?: (error: Error | unknown) => boolean;
entityType?: string; // 동기화 작업 유형 (예: '트랜잭션 업로드', '예산 다운로드' 등)
} = {}
): Promise<T> => {
const {
@@ -536,3 +547,14 @@ export const onNetworkStatusChange = (callback: (status: NetworkStatus) => void)
window.removeEventListener('networkStatusChange', handler);
};
};
/**
* 재시도 옵션 타입
*/
export type RetryOptions = {
maxRetries?: number;
retryDelay?: number;
onRetry?: (attempt: number, error: Error | unknown) => void;
shouldRetry?: (error: Error | unknown) => boolean;
entityType?: string; // 동기화 작업 유형 (예: '트랜잭션 업로드', '예산 다운로드' 등)
};

View File

@@ -12,7 +12,8 @@ import {
addToSyncQueue,
processPendingSyncQueue,
onNetworkStatusChange,
NetworkStatus
NetworkStatus,
RetryOptions
} from './networkUtils';
// Export all utility functions to maintain the same public API
@@ -80,6 +81,9 @@ export const initSyncState = async (): Promise<void> => {
// 온라인 상태로 변경되면 보류 중인 동기화 작업 처리
if (status === 'online') {
processPendingSyncQueue();
console.log('[네트워크 상태 변경] 온라인 상태로 변경되었습니다.');
} else {
console.log('[네트워크 상태 변경] 오프라인 상태로 변경되었습니다.');
}
});