Fix app onStart sync

(cherry picked from commit b430e31da4c6178a3f8e1502945b039f11751bef)
This commit is contained in:
Jobobby04 2024-11-03 22:44:31 -05:00 committed by Cuong-Tran
parent a27a44aea7
commit 2834fe9763
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -15,6 +15,8 @@ import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.work.Configuration
import androidx.work.WorkManager
import coil3.ImageLoader
import coil3.SingletonImageLoader
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
@ -192,6 +194,9 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
LogcatLogger.install(AndroidLogcatLogger(LogPriority.VERBOSE))
}*/
if (!WorkManager.isInitialized()) {
WorkManager.initialize(this, Configuration.Builder().build())
}
val syncPreferences: SyncPreferences = Injekt.get()
val syncTriggerOpt = syncPreferences.getSyncTriggerOptions()
if (syncPreferences.isSyncEnabled() && syncTriggerOpt.syncOnAppStart) {
@ -288,12 +293,6 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
} catch (e: Exception) {
logcat(LogPriority.ERROR, e) { "Failed to modify notification channels" }
}
val syncPreferences: SyncPreferences = Injekt.get()
val syncTriggerOpt = syncPreferences.getSyncTriggerOptions()
if (syncPreferences.isSyncEnabled() && syncTriggerOpt.syncOnAppStart) {
SyncDataJob.startNow(this@App)
}
}
// EXH