mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-12 02:19:44 +00:00
avoid error when clicking on federated user avatar
without this, there would be http 404 error (nothing was shown to user): 2024-04-11 15:34:30.612 18641-18641 ProfileBottomSheet com.nextcloud.talk2 E Failed to get hover card for user user@yourfereatedserver.dev retrofit2.adapter.rxjava2.HttpException: HTTP 404 at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:57) at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:38) at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:48) at io.reactivex.Observable.subscribe(Observable.java:12284) at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:35) at io.reactivex.Observable.subscribe(Observable.java:12284) at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96) at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:608) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307) 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) With this fix, nothing happens when clicking on a federated user avatar, just like in web and iOS. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
69e8c91431
commit
52dc82703e
@ -132,7 +132,7 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -118,7 +118,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -140,7 +140,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -140,7 +140,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -234,7 +234,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageAuthor.visibility = View.VISIBLE
|
||||
binding.messageAuthor.text = author
|
||||
binding.messageUserAvatar.setOnClickListener {
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
|
||||
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
|
||||
}
|
||||
} else {
|
||||
binding.messageAuthor.setText(R.string.nc_nick_guest)
|
||||
|
@ -172,7 +172,7 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
|
||||
userAvatar.setOnClickListener { v: View ->
|
||||
if (payload is MessagePayload) {
|
||||
(payload as MessagePayload).profileBottomSheet.showFor(
|
||||
message.actorId!!,
|
||||
message,
|
||||
v.context
|
||||
)
|
||||
}
|
||||
|
@ -21,9 +21,11 @@ import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.bottomsheet.items.BasicListItemWithImage
|
||||
import com.nextcloud.talk.bottomsheet.items.listItemsWithImage
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
import com.nextcloud.talk.models.json.hovercard.HoverCardAction
|
||||
import com.nextcloud.talk.models.json.hovercard.HoverCardOverall
|
||||
import com.nextcloud.talk.models.json.participants.Participant
|
||||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.EMAIL
|
||||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.PROFILE
|
||||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.SPREED
|
||||
@ -41,10 +43,15 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val viewThemeUti
|
||||
|
||||
private val allowedAppIds = listOf(SPREED.stringValue, PROFILE.stringValue, EMAIL.stringValue)
|
||||
|
||||
fun showFor(user: String, context: Context) {
|
||||
fun showFor(message: ChatMessage, context: Context) {
|
||||
if (message.actorType == Participant.ActorType.FEDERATED.toString()) {
|
||||
Log.d(TAG, "no actions for federated users are shown")
|
||||
return
|
||||
}
|
||||
|
||||
ncApi.hoverCard(
|
||||
ApiUtils.getCredentials(userModel.username, userModel.token),
|
||||
ApiUtils.getUrlForHoverCard(userModel.baseUrl!!, user)
|
||||
ApiUtils.getUrlForHoverCard(userModel.baseUrl!!, message.actorId!!)
|
||||
).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<HoverCardOverall> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
@ -55,13 +62,13 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val viewThemeUti
|
||||
bottomSheet(
|
||||
hoverCardOverall.ocs!!.data!!.actions!!,
|
||||
hoverCardOverall.ocs!!.data!!.displayName!!,
|
||||
user,
|
||||
message.actorId!!,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "Failed to get hover card for user $user", e)
|
||||
Log.e(TAG, "Failed to get hover card for user " + message.actorId, e)
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
|
Loading…
Reference in New Issue
Block a user