mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-18 19:19:33 +01:00
catch http 405 if endpoint is not available.
E.g. for older server versions Without this fix there would be the crash: E FATAL EXCEPTION: main Process: com.nextcloud.talk2, PID: 7161 retrofit2.HttpException: HTTP 405 at retrofit2.KotlinExtensions$await$2$2.onResponse(KotlinExtensions.kt:53) at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:164) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4a67b41, Dispatchers.Main.immediate] Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
4efba2b953
commit
27ba2acf86
@ -319,14 +319,19 @@ class ConversationInfoViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
fun getProfileData(user: User, userId: String) {
|
||||
val url = ApiUtils.getUrlForProfile(user.baseUrl!!, userId)
|
||||
viewModelScope.launch {
|
||||
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
|
||||
if (profile != null) {
|
||||
_getProfileViewState.value = GetProfileSuccessState(profile)
|
||||
} else {
|
||||
_getProfileViewState.value = GetProfileErrorState
|
||||
try {
|
||||
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
|
||||
if (profile != null) {
|
||||
_getProfileViewState.value = GetProfileSuccessState(profile)
|
||||
} else {
|
||||
_getProfileViewState.value = GetProfileErrorState
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to get profile data (if not supported there wil be http405)", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user