diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d3f95a0..8873cc2 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1927,7 +1927,7 @@ function App() { markets={monitoredMarkets} marketSubscriptions={liveStompSubscriptions} activeMarket={symbol} - enabled={formalLogin && monitoredMarkets.length > 0} + enabled={formalLogin && monitoredMarkets.length > 0 && appSettingsLoaded} popupEnabled={appDefaults.tradeAlertPopup ?? true} chartMarkersActive={menuPage === 'chart'} onMarkersChange={markers => { diff --git a/frontend/src/hooks/useAppSettings.ts b/frontend/src/hooks/useAppSettings.ts index aa682ad..979108c 100644 --- a/frontend/src/hooks/useAppSettings.ts +++ b/frontend/src/hooks/useAppSettings.ts @@ -79,6 +79,14 @@ export function getAppSettingsCache(): AppSettingsDto { return _cache ?? {}; } +/** 낙관적 캐시 패치 — _cache 가 null 일 때도 다음 로드 전까지 임시 보관 */ +export function patchAppSettingsCache(patch: Partial): void { + if (_cache !== null) { + Object.assign(_cache, patch); + } + // _cache 가 null 이면 현재 로드 중이므로 건너뜀 (로드 완료 후 DB 저장값으로 덮어씌워짐) +} + export function subscribeAppSettings(listener: AppSettingsListener): () => void { _listeners.add(listener); return () => _listeners.delete(listener); diff --git a/frontend/src/utils/uiPreferencesDb.ts b/frontend/src/utils/uiPreferencesDb.ts index 618bcd4..cc31af4 100644 --- a/frontend/src/utils/uiPreferencesDb.ts +++ b/frontend/src/utils/uiPreferencesDb.ts @@ -3,9 +3,10 @@ */ import { getAppSettingsCache, + patchAppSettingsCache, subscribeAppSettings, } from '../hooks/useAppSettings'; -import { saveAppSettings, type AppSettingsDto } from './backendApi'; +import { saveAppSettings } from './backendApi'; import { EMPTY_UI_PREFERENCES, UI_PREFERENCES_VERSION, @@ -64,9 +65,7 @@ export function patchUiPreferences(patch: Partial, immediate = fa const next = deepMerge(current as Record, patch as Record) as UiPreferences; next.v = UI_PREFERENCES_VERSION; - const cache = getAppSettingsCache(); - const merged: AppSettingsDto = { ...cache, uiPreferences: next }; - Object.assign(cache, merged); + patchAppSettingsCache({ uiPreferences: next }); pendingPatch = pendingPatch ? (deepMerge(pendingPatch as Record, patch as Record) as Partial)