Files
zellyy-finance/src/hooks/sync/syncNetworkChecker.ts
hansoo 9851627ff1 feat: Add CI/CD pipeline and code quality improvements
- Add GitHub Actions workflow for automated CI/CD
- Configure Node.js 18.x and 20.x matrix testing
- Add TypeScript type checking step
- Add ESLint code quality checks with enhanced rules
- Add Prettier formatting verification
- Add production build validation
- Upload build artifacts for deployment
- Set up automated testing on push/PR
- Replace console.log with environment-aware logger
- Add pre-commit hooks for code quality
- Exclude archive folder from linting

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-12 15:27:54 +09:00

53 lines
1.5 KiB
TypeScript

import { checkNetworkStatus } from "@/utils/network/checker";
import { syncLogger } from "@/utils/logger";
import { toast } from "@/hooks/useToast.wrapper";
/**
* 동기화를 위한 네트워크 상태 확인
*/
export const checkSyncNetworkStatus = async (): Promise<boolean> => {
// 기본 네트워크 상태 확인 - navigator.onLine 우선 사용
const navigatorOnline = navigator.onLine;
syncLogger.info(
`[동기화] 기본 네트워크 상태 확인: ${navigatorOnline ? "온라인" : "오프라인"}`
);
if (!navigatorOnline) {
return false;
}
// 강화된 네트워크 확인 시도 (실패해도 계속 진행)
try {
const isOnline = await checkNetworkStatus();
syncLogger.info(
`[동기화] 강화된 네트워크 확인 결과: ${isOnline ? "온라인" : "오프라인"}`
);
return isOnline;
} catch (error) {
// 네트워크 확인 실패해도 navigator.onLine이 true면 진행
syncLogger.warn(
"[동기화] 강화된 네트워크 확인 실패, 기본 상태 사용:",
error
);
return navigatorOnline;
}
};
/**
* 네트워크 오류 시 알림 표시
*/
export const showNetworkErrorNotification = (
addNotification: (title: string, message: string) => void
) => {
const title = "네트워크 연결 필요";
const description = "동기화를 위해 인터넷 연결이 필요합니다.";
toast({
title,
description,
variant: "destructive",
});
addNotification(title, description);
};