v0.3.3: fix dead code in initializeApp - split coroutines

This commit is contained in:
sanjeok77 committed 2026-08-24 23:02:06 +00:00
1 parent 984cc0bd85
commit a4a6492945
1 file changed
+9 -2
@@ -44,11 +44,18 @@ class MainViewModel @Inject constructor(
}
private fun initializeApp() {
// 1. 사이트 설정 초기화 후 DB Flow 구독 (별도 코루틴 — collect는 영원히 suspend)
viewModelScope.launch {
initializeDefaultSiteConfigs()
loadState()
loadState() // combine().collect — 이 코루틴은 영원히 살아있음
}
// 2. 백그라운드 폴링 등록 + 즉시 1회 스크래핑 (별도 코루틴)
viewModelScope.launch {
val savedInterval = appSettings.pollingInterval.first()
startPolling(savedInterval.toLong())
workerScheduler.schedulePeriodicPolling(savedInterval.toLong())
// 앱 시작 시 즉시 1회 실행하여 최신 데이터 갱신
workerScheduler.executeOnce()
}
}