mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-18 19:19:33 +01:00
Merge pull request #5035 from nextcloud/bugfix/4983/fixCrashForHttp405ForProfileData
Profile data in ConversationInfo: catch http 405 if endpoint is not available
This commit is contained in:
commit
e88bd1caf7
@ -319,14 +319,19 @@ class ConversationInfoViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
fun getProfileData(user: User, userId: String) {
|
fun getProfileData(user: User, userId: String) {
|
||||||
val url = ApiUtils.getUrlForProfile(user.baseUrl!!, userId)
|
val url = ApiUtils.getUrlForProfile(user.baseUrl!!, userId)
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
|
try {
|
||||||
if (profile != null) {
|
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
|
||||||
_getProfileViewState.value = GetProfileSuccessState(profile)
|
if (profile != null) {
|
||||||
} else {
|
_getProfileViewState.value = GetProfileSuccessState(profile)
|
||||||
_getProfileViewState.value = GetProfileErrorState
|
} 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