From e031ec5de5fd033928db3b8d8307bc519339589f Mon Sep 17 00:00:00 2001 From: Fabian Devel Date: Fri, 18 Oct 2024 15:51:23 +0200 Subject: [PATCH] fix(InfiniteLoading): Fix inifinite loading in SyncSettingsActivity --- .../ui/menu/settings/SyncSettingsActivity.kt | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/settings/SyncSettingsActivity.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/settings/SyncSettingsActivity.kt index 796aa312d7..d4506bf320 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/settings/SyncSettingsActivity.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/settings/SyncSettingsActivity.kt @@ -53,6 +53,8 @@ import com.infomaniak.drive.utils.SyncUtils.activateAutoSync import com.infomaniak.drive.utils.SyncUtils.disableAutoSync import com.infomaniak.drive.utils.Utils import com.infomaniak.lib.core.utils.* +import com.infomaniak.lib.core.utils.SnackbarUtils.showSnackbar +import io.sentry.Sentry import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.invoke import kotlinx.coroutines.launch @@ -367,17 +369,27 @@ class SyncSettingsActivity : BaseActivity() { private fun saveSettings() = with(binding) { saveButton.showProgressCatching() lifecycleScope.launch(Dispatchers.IO) { - if (activateSyncSwitch.isChecked) { - val syncSettings = generateSyncSettings() - trackPhotoSyncEvents(syncSettings) - syncSettings.setIntervalType(syncSettingsViewModel.syncIntervalType.value!!) - UploadFile.setAppSyncSettings(syncSettings) - activateAutoSync(syncSettings) - } else { - disableAutoSync() - } + runCatching { + if (activateSyncSwitch.isChecked) { + val syncSettings = generateSyncSettings() + trackPhotoSyncEvents(syncSettings) + syncSettings.setIntervalType(syncSettingsViewModel.syncIntervalType.value!!) + UploadFile.setAppSyncSettings(syncSettings) + activateAutoSync(syncSettings) + } else { + disableAutoSync() + } - trackPhotoSyncEvent(if (activateSyncSwitch.isChecked) "enabled" else "disabled") + trackPhotoSyncEvent(if (activateSyncSwitch.isChecked) "enabled" else "disabled") + }.onFailure { + it.printStackTrace() + showSnackbar(R.string.anErrorHasOccurred) + Sentry.captureException(it) { scope -> + scope.setTag("syncIntervalType", syncSettingsViewModel.syncIntervalType.value?.title.toString()) + scope.setTag("createMonthFolder", createDatedSubFoldersSwitch.isChecked.toString()) + scope.setTag("deletePhoto", deletePicturesAfterSyncSwitch.isChecked.toString()) + } + } Dispatchers.Main { saveButton.hideProgressCatching(R.string.buttonSave)