mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
Merge pull request #5036 from nextcloud/backport/5035/stable-21.1
[stable-21.1] Profile data in ConversationInfo: catch http 405 if endpoint is not available
This commit is contained in:
commit
26aece63fc
@ -319,15 +319,20 @@ 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 {
|
||||||
|
try {
|
||||||
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
|
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
_getProfileViewState.value = GetProfileSuccessState(profile)
|
_getProfileViewState.value = GetProfileSuccessState(profile)
|
||||||
} else {
|
} else {
|
||||||
_getProfileViewState.value = GetProfileErrorState
|
_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