mobile download
This commit is contained in:
@@ -49,6 +49,7 @@ import {
|
||||
resolveChartPaneSeparatorOptions,
|
||||
type ChartPaneSeparatorOptions,
|
||||
} from '../types/chartPaneSeparator';
|
||||
import { migrateLocalStorageToUiPreferences } from '../utils/uiPreferencesMigrate';
|
||||
|
||||
// 전역 캐시 — 여러 컴포넌트에서 공유하여 중복 요청 방지
|
||||
let _cache: AppSettingsDto | null = null;
|
||||
@@ -73,8 +74,18 @@ export function subscribeAppSettings(listener: AppSettingsListener): () => void
|
||||
function ensureLoaded(): Promise<AppSettingsDto> {
|
||||
if (_cache !== null) return Promise.resolve(_cache);
|
||||
if (_loadPromise) return _loadPromise;
|
||||
_loadPromise = loadAppSettings().then(data => {
|
||||
_loadPromise = loadAppSettings().then(async data => {
|
||||
_cache = data ?? {};
|
||||
const migrated = migrateLocalStorageToUiPreferences(_cache);
|
||||
if (migrated?.changed) {
|
||||
try {
|
||||
const saved = await saveAppSettings({ uiPreferences: migrated.uiPreferences });
|
||||
_cache = { ..._cache, ...saved, uiPreferences: migrated.uiPreferences };
|
||||
} catch (e) {
|
||||
console.warn('[useAppSettings] uiPreferences 마이그레이션 저장 실패:', e);
|
||||
_cache = { ..._cache, uiPreferences: migrated.uiPreferences };
|
||||
}
|
||||
}
|
||||
_loadPromise = null;
|
||||
notifyAppSettingsListeners();
|
||||
return _cache;
|
||||
|
||||
Reference in New Issue
Block a user