From 6d0dbf1c56f982042981e97f7a132493ce339e99 Mon Sep 17 00:00:00 2001 From: KaiserBh Date: Wed, 10 Jan 2024 21:03:44 +1100 Subject: [PATCH 1/2] refactor Signed-off-by: KaiserBh --- .../tachiyomi/data/sync/service/GoogleDriveSyncService.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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() From f5b10cd07f294a569ef5417ca487a5cf3baf8e69 Mon Sep 17 00:00:00 2001 From: KaiserBh Date: Fri, 12 Jan 2024 02:01:15 +1100 Subject: [PATCH 2/2] feat: add a way to reset last_sync_timestamp. --- .../settings/screen/SettingsAdvancedScreen.kt | 21 +++++++++++++++++++ .../commonMain/resources/MR/base/strings.xml | 3 +++ 2 files changed, 24 insertions(+) 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/i18n/src/commonMain/resources/MR/base/strings.xml b/i18n/src/commonMain/resources/MR/base/strings.xml index e0ba8bec1..1b6df365e 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