Skip to content

Commit

Permalink
fix: Show a snackbar when a conflict error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyDL-Infomaniak authored and KevinBoulongne committed Feb 25, 2025
1 parent e5434ee commit a4ab96c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ class TrashedFileActionsBottomSheetDialog : BottomSheetDialogFragment() {
}
}

private fun getErrorMessage(fileResult: FileResult) = when (fileResult.errorCode) {
ApiErrorCode.AN_ERROR_HAS_OCCURRED -> R.string.errorRestore
"conflict_error" -> R.string.errorConflict
else -> fileResult.errorResId
}

private fun restoreResult(fileResult: FileResult, originalPlace: Boolean, folderName: String? = null) {
if (fileResult.isSuccess) {
val title = if (originalPlace) R.plurals.trashedFileRestoreFileToOriginalPlaceSuccess
Expand All @@ -125,8 +131,7 @@ class TrashedFileActionsBottomSheetDialog : BottomSheetDialogFragment() {
showSnackbar(resources.getQuantityString(title, 1, *args.toTypedArray()))
dismissAndRemoveFileFromList()
} else {
val snackbarText = if (fileResult.errorCode == ApiErrorCode.AN_ERROR_HAS_OCCURRED) R.string.errorRestore
else fileResult.errorResId
val snackbarText = getErrorMessage(fileResult)

snackbarText?.let { text -> showSnackbar(text) }
findNavController().popBackStack()
Expand Down

0 comments on commit a4ab96c

Please sign in to comment.