Resolve crash when submitting feedback without internet access (#6018)

* fix: resolve crash when submitting feedback without internet access

* feat:Added check for wheather internet connection was available for a network

* feat:Added SnackBar for Retry and User Info

* feat:Made the feedback dialog not leave screen in case of error

* feat:Removed the network checking from the function

* feat:Added try catch block for the Feedback

* feat:Removed Unnecessary imports

* feat:Used Snackbar and timber instead of log and Toast

---------

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Gautham Mohanraj 2024-12-13 19:00:30 +05:30 committed by GitHub
parent f51b607312
commit b2810bcef1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 4 deletions

View file

@ -35,6 +35,7 @@ import fr.free.nrw.commons.settings.SettingsActivity
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Named
@ -182,14 +183,17 @@ class MoreBottomSheetFragment : BottomSheetDialogFragment() {
Single.defer { single }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { success ->
.subscribe({ success ->
val messageResId = if (success) {
R.string.thanks_feedback
} else {
R.string.error_feedback
}
Toast.makeText(requireContext(), getString(messageResId), Toast.LENGTH_SHORT).show()
}
}, { error ->
Timber.e(error)
Toast.makeText(requireContext(), R.string.error_feedback, Toast.LENGTH_SHORT).show()
})
}
/**