From 6b204b516595b3b0edc5a1b071930231a3c40efc Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 14 Feb 2019 04:46:43 +0100 Subject: [PATCH] Fix guest author location Signed-off-by: Mario Danic --- .../nextcloud/talk/controllers/ChatController.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java index a1c0b54fc..9c785a78a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java @@ -157,6 +157,8 @@ public class ChatController extends BaseController implements MessagesListAdapte private boolean wasDetached; private EmojiPopup emojiPopup; + private CharSequence myFirstMessage; + public ChatController(Bundle args) { super(args); setHasOptionsMenu(true); @@ -675,6 +677,8 @@ public class ChatController extends BaseController implements MessagesListAdapte @Override public void onNext(GenericOverall genericOverall) { + myFirstMessage = message; + if (popupBubble != null && popupBubble.isShown()) { popupBubble.hide(); } @@ -689,6 +693,8 @@ public class ChatController extends BaseController implements MessagesListAdapte if (e instanceof HttpException) { int code = ((HttpException) e).code(); if (Integer.toString(code).startsWith("2")) { + myFirstMessage = message; + if (popupBubble != null && popupBubble.isShown()) { popupBubble.hide(); } @@ -878,6 +884,13 @@ public class ChatController extends BaseController implements MessagesListAdapte chatMessage.setBaseUrl(conversationUser.getBaseUrl()); chatMessageList.get(i).setActiveUserId(conversationUser.getUserId()); + if (conversationUser.getUserId().equals("?") && !TextUtils.isEmpty(myFirstMessage.toString())) { + if (chatMessage.getActorType().equals("guests")) { + conversationUser.setUserId(chatMessage.getActorId()); + setSenderId(); + } + } + boolean shouldScroll = layoutManager.findFirstVisibleItemPosition() == 0 || (adapter != null && adapter.getItemCount() == 0);