Fix: Update version info on settings page

Investigates and resolves the issue where the app version and build number were not updating correctly on the settings page.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-23 10:49:21 +00:00
parent 8168d4b645
commit d2d0493ffd
6 changed files with 128 additions and 28 deletions

View File

@@ -1,3 +1,4 @@
import React, { useCallback, useEffect, useState, useRef } from 'react';
import { getAppVersionInfo, isAndroidPlatform } from '@/utils/platform';
import { Label } from '@/components/ui/label';
@@ -17,6 +18,8 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
versionName: string;
buildNumber: number;
versionCode?: number;
platform?: string;
pluginResponse?: string;
}>({
versionName: '1.0.1',
buildNumber: 2
@@ -44,10 +47,19 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
if (!info || typeof info !== 'object') {
throw new Error('유효하지 않은 응답 형식');
}
// 유효한 빌드 번호인지 확인하고 숫자로 변환
let buildNumber = info.buildNumber;
if (typeof buildNumber === 'string') {
buildNumber = parseInt(buildNumber, 10);
}
setVersionInfo({
versionName: info.versionName,
buildNumber: info.buildNumber,
versionCode: info.versionCode
versionName: info.versionName || '1.0.1',
buildNumber: isNaN(buildNumber) ? 2 : buildNumber,
versionCode: info.versionCode,
platform: info.platform,
pluginResponse: info.pluginResponse
});
setLoading(false);
@@ -70,12 +82,19 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
// 컴포넌트 마운트 시 즉시 실행 (IIFE)
useEffect(() => {
let isMounted = true;
(async () => {
// 즉시 버전 정보 가져오기 시도
await fetchVersionInfo();
// 컴포넌트가 언마운트되었는지 확인
if (!isMounted) return;
// 1000ms 후에 한번 더 시도 (네이티브 플러그인이 완전히 로드되지 않았을 경우 대비)
setTimeout(() => {
if (!isMounted) return;
if (error || loading) {
fetchVersionInfo();
initialLoadAttemptedRef.current = true;
@@ -84,13 +103,21 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
})();
// 개발 모드에서는 버전 정보 변경을 쉽게 확인하기 위해 주기적 갱신
let interval: number | undefined;
if (process.env.NODE_ENV === 'development') {
const interval = setInterval(() => {
fetchVersionInfo();
interval = window.setInterval(() => {
if (isMounted) {
fetchVersionInfo();
}
}, 30000); // 30초마다 새로 가져오기
return () => clearInterval(interval);
}
return () => {
isMounted = false;
if (interval) {
clearInterval(interval);
}
};
}, [fetchVersionInfo, error, loading]);
return (
@@ -122,6 +149,11 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
versionCode: {versionInfo.versionCode}
</p>
)}
{showDevInfo && versionInfo.platform && (
<p className="text-xs text-gray-400 mt-1 font-mono">
: {versionInfo.platform}
</p>
)}
{editable && (
<p className="text-gray-400 font-semibold text-sm mt-2">ZELLYY CLOUD</p>
)}