diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index 4b8f2b9d7..833a4a1a2 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -63,6 +63,7 @@ import tachiyomi.core.util.lang.launchNonCancellable import tachiyomi.core.util.lang.withUIContext import tachiyomi.core.util.system.logcat import tachiyomi.domain.manga.interactor.ResetViewerFlags +import tachiyomi.domain.sync.SyncPreferences import tachiyomi.i18n.MR import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.util.collectAsState @@ -142,6 +143,7 @@ object SettingsAdvancedScreen : SearchableSettings { getNetworkGroup(networkPreferences = networkPreferences), getLibraryGroup(), getExtensionsGroup(basePreferences = basePreferences), + getSyncGroup(), ), ) } @@ -404,4 +406,23 @@ object SettingsAdvancedScreen : SearchableSettings { ), ) } + + @Composable + private fun getSyncGroup(): Preference.PreferenceGroup { + val context = LocalContext.current + val syncPreferences = remember { Injekt.get() } + return Preference.PreferenceGroup( + title = stringResource(MR.strings.label_sync), + preferenceItems = persistentListOf( + Preference.PreferenceItem.TextPreference( + title = stringResource(MR.strings.pref_reset_sync_timestamp), + subtitle = stringResource(MR.strings.pref_reset_sync_timestamp_subtitle), + onClick = { + syncPreferences.lastSyncTimestamp().set(0) + context.toast(MR.strings.success_reset_sync_timestamp) + }, + ), + ), + ) + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/sync/service/GoogleDriveSyncService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/sync/service/GoogleDriveSyncService.kt index 48f10d7d4..cd1ba9a89 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/sync/service/GoogleDriveSyncService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/sync/service/GoogleDriveSyncService.kt @@ -151,14 +151,13 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync } override suspend fun pushSyncData(syncData: SyncData) { + val jsonData = json.encodeToString(syncData) val drive = googleDriveService.driveService ?: throw Exception(context.stringResource(MR.strings.google_drive_not_signed_in)) val fileList = getAppDataFileList(drive) val byteArrayOutputStream = ByteArrayOutputStream() - withContext(Dispatchers.IO) { - val jsonData = json.encodeToString(syncData) val gzipOutputStream = GZIPOutputStream(byteArrayOutputStream) gzipOutputStream.write(jsonData.toByteArray(Charsets.UTF_8)) gzipOutputStream.close() diff --git a/i18n/src/commonMain/resources/MR/base/strings.xml b/i18n/src/commonMain/resources/MR/base/strings.xml index 6ce3e9d97..bbb02a4e9 100644 --- a/i18n/src/commonMain/resources/MR/base/strings.xml +++ b/i18n/src/commonMain/resources/MR/base/strings.xml @@ -561,6 +561,9 @@ Sync Automatic Synchronization Synchronization frequency + Reset last sync timestamp + Reset the last sync timestamp to force a full sync + Last sync timestamp reset SyncYomi Done in %1$s Last Synchronization: %1$s