diff --git a/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/AccountSettingsViewModel.kt b/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/AccountSettingsViewModel.kt index 407af03c..63dd23d3 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/AccountSettingsViewModel.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/AccountSettingsViewModel.kt @@ -124,24 +124,24 @@ class AccountSettingsViewModel @Inject internal constructor( } } + @RequiresApi(Build.VERSION_CODES.O) private fun displayBackup() { viewModelScope.launch { settingsRepository.displayBackup().collect { result -> when (result.code()) { - ResponseCode.SUCCESS.value -> {} - ResponseCode.NO_INTERNET_CONNECTION.value -> { - handleNoInternetConnection() - } + ResponseCode.SUCCESS.value -> { symbolListBackup() } + ResponseCode.NO_INTERNET_CONNECTION.value -> { handleNoInternetConnection() } } } } } + @RequiresApi(Build.VERSION_CODES.O) private fun symbolListBackup() { viewModelScope.launch { settingsRepository.symbolListBackup().collect { result -> when (result.code()) { - ResponseCode.SUCCESS.value -> {} + ResponseCode.SUCCESS.value -> { favoriteSymbolBackup() } ResponseCode.NO_INTERNET_CONNECTION.value -> { handleNoInternetConnection() @@ -153,11 +153,12 @@ class AccountSettingsViewModel @Inject internal constructor( } + @RequiresApi(Build.VERSION_CODES.O) private fun favoriteSymbolBackup() { viewModelScope.launch { settingsRepository.favoriteSymbolBackup().collect { result -> when (result.code()) { - ResponseCode.SUCCESS.value -> {} + ResponseCode.SUCCESS.value -> { weightTableBackup() } ResponseCode.NO_INTERNET_CONNECTION.value -> { handleNoInternetConnection() @@ -193,9 +194,6 @@ class AccountSettingsViewModel @Inject internal constructor( ) } displayBackup() - symbolListBackup() - favoriteSymbolBackup() - weightTableBackup() } private fun handleNoInternetConnection() { diff --git a/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/BackupSettingsViewModel.kt b/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/BackupSettingsViewModel.kt index dd8e52de..c62e7c56 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/BackupSettingsViewModel.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/BackupSettingsViewModel.kt @@ -94,11 +94,12 @@ class BackupSettingsViewModel @Inject internal constructor( } } + @RequiresApi(Build.VERSION_CODES.O) private fun displayBackup() { viewModelScope.launch { repository.displayBackup().collect { result -> when (result.code()) { - ResponseCode.SUCCESS.value -> {} + ResponseCode.SUCCESS.value -> { symbolListBackup() } ResponseCode.NO_INTERNET_CONNECTION.value -> { handleNoInternetConnection() } } @@ -106,12 +107,12 @@ class BackupSettingsViewModel @Inject internal constructor( } } + @RequiresApi(Build.VERSION_CODES.O) private fun symbolListBackup() { - viewModelScope.launch { repository.symbolListBackup().collect { result -> when (result.code()) { - ResponseCode.SUCCESS.value -> {} + ResponseCode.SUCCESS.value -> { favoriteSymbolBackup() } ResponseCode.NO_INTERNET_CONNECTION.value -> { handleNoInternetConnection() } } @@ -121,11 +122,12 @@ class BackupSettingsViewModel @Inject internal constructor( } + @RequiresApi(Build.VERSION_CODES.O) private fun favoriteSymbolBackup() { viewModelScope.launch { repository.favoriteSymbolBackup().collect { result -> when (result.code()) { - ResponseCode.SUCCESS.value -> {} + ResponseCode.SUCCESS.value -> { weightTableBackup() } ResponseCode.NO_INTERNET_CONNECTION.value -> { handleNoInternetConnection() } } @@ -150,9 +152,6 @@ class BackupSettingsViewModel @Inject internal constructor( fun backup() { changeLoadingState() displayBackup() - symbolListBackup() - favoriteSymbolBackup() - weightTableBackup() } private fun handleNoInternetConnection() {