diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/data/SyncOptionsScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/data/SyncOptionsScreen.kt index 27c1255af..e810d1c75 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/data/SyncOptionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/data/SyncOptionsScreen.kt @@ -9,6 +9,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.rememberScreenModel @@ -21,13 +22,12 @@ import kotlinx.collections.immutable.minus import kotlinx.collections.immutable.plus import kotlinx.collections.immutable.toPersistentSet import kotlinx.coroutines.flow.update +import tachiyomi.domain.sync.SyncPreferences import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.LabeledCheckbox import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.stringResource -import androidx.compose.runtime.getValue -import tachiyomi.domain.sync.SyncPreferences import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -110,7 +110,6 @@ private class SyncOptionsScreenModel : StateScreenModel = SyncChoices.keys.toPersistentSet(), @@ -122,4 +121,3 @@ private val SyncChoices = mapOf( SyncPreferences.Flags.SYNC_ON_CHAPTER_OPEN to MR.strings.sync_on_chapter_open, SyncPreferences.Flags.SYNC_ON_APP_START to MR.strings.sync_on_app_start, ) - diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 59072b5b6..8434071df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -176,7 +176,6 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory { if (syncPreferences.syncService().get() != 0 && syncFlags and SyncPreferences.Flags.SYNC_ON_APP_START == SyncPreferences.Flags.SYNC_ON_APP_START) { SyncDataJob.startNow(this@App) } - } override fun onStop(owner: LifecycleOwner) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 1f4abd66c..557b34c4b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -100,7 +100,7 @@ class ReaderViewModel @JvmOverloads constructor( private val upsertHistory: UpsertHistory = Injekt.get(), private val updateChapter: UpdateChapter = Injekt.get(), private val setMangaViewerFlags: SetMangaViewerFlags = Injekt.get(), - private val syncPreferences: SyncPreferences = Injekt.get() + private val syncPreferences: SyncPreferences = Injekt.get(), ) : ViewModel() { private val mutableState = MutableStateFlow(State()) @@ -534,7 +534,8 @@ class ReaderViewModel @JvmOverloads constructor( // Check if syncing is enabled for chapter read: if (syncPreferences.syncService().get() != 0 && - syncFlags and SyncPreferences.Flags.SYNC_ON_CHAPTER_READ == SyncPreferences.Flags.SYNC_ON_CHAPTER_READ) { + syncFlags and SyncPreferences.Flags.SYNC_ON_CHAPTER_READ == SyncPreferences.Flags.SYNC_ON_CHAPTER_READ + ) { SyncDataJob.startNow(Injekt.get()) } } @@ -549,7 +550,8 @@ class ReaderViewModel @JvmOverloads constructor( // Check if syncing is enabled for chapter open: if (syncPreferences.syncService().get() != 0 && - syncFlags and SyncPreferences.Flags.SYNC_ON_CHAPTER_OPEN == SyncPreferences.Flags.SYNC_ON_CHAPTER_OPEN) { + syncFlags and SyncPreferences.Flags.SYNC_ON_CHAPTER_OPEN == SyncPreferences.Flags.SYNC_ON_CHAPTER_OPEN + ) { SyncDataJob.startNow(Injekt.get()) } } diff --git a/domain/src/main/java/tachiyomi/domain/sync/SyncPreferences.kt b/domain/src/main/java/tachiyomi/domain/sync/SyncPreferences.kt index 630d82622..509124a9e 100644 --- a/domain/src/main/java/tachiyomi/domain/sync/SyncPreferences.kt +++ b/domain/src/main/java/tachiyomi/domain/sync/SyncPreferences.kt @@ -17,7 +17,6 @@ class SyncPreferences( fun values() = listOf(NONE, SYNC_ON_CHAPTER_READ, SYNC_ON_CHAPTER_OPEN, SYNC_ON_APP_START) } - fun syncHost() = preferenceStore.getString("sync_host", "https://sync.tachiyomi.org") fun syncAPIKey() = preferenceStore.getString("sync_api_key", "") fun lastSyncTimestamp() = preferenceStore.getLong(Preference.appStateKey("last_sync_timestamp"), 0L) @@ -35,5 +34,5 @@ class SyncPreferences( "", ) - fun syncFlags() = preferenceStore.getInt("sync_flags", Flags.Defaults) + fun syncFlags() = preferenceStore.getInt("sync_flags", Flags.Defaults) }