mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 06:44:09 +01:00
Fix messages stuff
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
07e11d8903
commit
3f374ca232
@ -998,13 +998,14 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
fieldMap.put("includeLastKnown", 0);
|
fieldMap.put("includeLastKnown", 0);
|
||||||
|
|
||||||
int timeout = 30;
|
int timeout = 30;
|
||||||
if (!lookingIntoFuture ) {
|
if (lookIntoFuture == 0) {
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldMap.put("timeout", timeout);
|
||||||
|
|
||||||
if (lookIntoFuture > 0) {
|
if (lookIntoFuture > 0) {
|
||||||
lookingIntoFuture = true;
|
lookingIntoFuture = true;
|
||||||
fieldMap.put("timeout", timeout);
|
|
||||||
} else if (isFirstMessagesProcessing) {
|
} else if (isFirstMessagesProcessing) {
|
||||||
globalLastKnownFutureMessageId = currentConversation.getLastReadMessage();
|
globalLastKnownFutureMessageId = currentConversation.getLastReadMessage();
|
||||||
globalLastKnownPastMessageId = currentConversation.getLastReadMessage();
|
globalLastKnownPastMessageId = currentConversation.getLastReadMessage();
|
||||||
@ -1024,6 +1025,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
|
|
||||||
fieldMap.put("lastKnownMessageId", lastKnown);
|
fieldMap.put("lastKnownMessageId", lastKnown);
|
||||||
|
|
||||||
|
Log.d("MARIO-PUSH", lastKnown + " " + lookIntoFuture);
|
||||||
if (!wasDetached) {
|
if (!wasDetached) {
|
||||||
if (lookIntoFuture > 0) {
|
if (lookIntoFuture > 0) {
|
||||||
int finalTimeout = timeout;
|
int finalTimeout = timeout;
|
||||||
@ -1051,9 +1053,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
if (!currentConversation.shouldShowLobby(conversationUser)) {
|
|
||||||
pullChatMessages(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1090,23 +1090,27 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processMessages(Response response, boolean isFromTheFuture, int timeout) {
|
private void processMessages(Response response, boolean isFromTheFuture, int timeout) {
|
||||||
if (response.code() == 200) {
|
String xChatLastGivenHeader;
|
||||||
|
if (response.headers().size() > 0 && !TextUtils.isEmpty((xChatLastGivenHeader = response.headers().get("X-Chat-Last-Given")))) {
|
||||||
|
|
||||||
String xChatLastGivenHeader;
|
int header = Integer.parseInt(xChatLastGivenHeader);
|
||||||
if (response.headers().size() > 0 && !TextUtils.isEmpty((xChatLastGivenHeader = response.headers().get
|
if (header > 0) {
|
||||||
("X-Chat-Last-Given")))) {
|
if (isFromTheFuture) {
|
||||||
if (xChatLastGivenHeader != null) {
|
globalLastKnownFutureMessageId = header;
|
||||||
if (isFromTheFuture) {
|
} else {
|
||||||
globalLastKnownFutureMessageId = Integer.parseInt(xChatLastGivenHeader);
|
globalLastKnownPastMessageId = header;
|
||||||
} else {
|
|
||||||
globalLastKnownPastMessageId = Integer.parseInt(xChatLastGivenHeader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d("MARIO-PUSH PROCESSING", String.valueOf(isFromTheFuture));
|
||||||
|
if (response.code() == 200) {
|
||||||
|
|
||||||
ChatOverall chatOverall = (ChatOverall) response.body();
|
ChatOverall chatOverall = (ChatOverall) response.body();
|
||||||
List<ChatMessage> chatMessageList = chatOverall.getOcs().getData();
|
List<ChatMessage> chatMessageList = chatOverall.getOcs().getData();
|
||||||
|
|
||||||
|
boolean wasFirstMessageProcessing = isFirstMessagesProcessing;
|
||||||
|
|
||||||
if (isFirstMessagesProcessing) {
|
if (isFirstMessagesProcessing) {
|
||||||
cancelNotificationsForCurrentConversation();
|
cancelNotificationsForCurrentConversation();
|
||||||
|
|
||||||
@ -1124,6 +1128,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
int countGroupedMessages = 0;
|
int countGroupedMessages = 0;
|
||||||
if (!isFromTheFuture) {
|
if (!isFromTheFuture) {
|
||||||
|
|
||||||
|
Log.d("MARIO-PUSH", "ADDING MESSAGES TO PAST " + chatMessageList.size());
|
||||||
for (int i = 0; i < chatMessageList.size(); i++) {
|
for (int i = 0; i < chatMessageList.size(); i++) {
|
||||||
if (chatMessageList.size() > i + 1) {
|
if (chatMessageList.size() > i + 1) {
|
||||||
if (TextUtils.isEmpty(chatMessageList.get(i).getSystemMessage()) &&
|
if (TextUtils.isEmpty(chatMessageList.get(i).getSystemMessage()) &&
|
||||||
@ -1144,6 +1149,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
chatMessage.setActiveUser(conversationUser);
|
chatMessage.setActiveUser(conversationUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wasFirstMessageProcessing) {
|
||||||
|
globalLastKnownFutureMessageId = chatMessageList.get(0).getJsonMessageId();
|
||||||
|
}
|
||||||
|
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
adapter.addToEnd(chatMessageList, false);
|
adapter.addToEnd(chatMessageList, false);
|
||||||
}
|
}
|
||||||
@ -1166,6 +1175,8 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
|
|
||||||
boolean isThereANewNotice = shouldAddNewMessagesNotice || adapter.getMessagePositionByIdInReverse("-1") != -1;
|
boolean isThereANewNotice = shouldAddNewMessagesNotice || adapter.getMessagePositionByIdInReverse("-1") != -1;
|
||||||
|
|
||||||
|
Log.d("MARIO-PUSH", "ADDING MESSAGES TO FUTURE " + chatMessageList.size());
|
||||||
|
|
||||||
for (int i = 0; i < chatMessageList.size(); i++) {
|
for (int i = 0; i < chatMessageList.size(); i++) {
|
||||||
chatMessage = chatMessageList.get(i);
|
chatMessage = chatMessageList.get(i);
|
||||||
|
|
||||||
@ -1209,20 +1220,20 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lookingIntoFuture && inChat) {
|
if (inChat) {
|
||||||
pullChatMessages(1);
|
pullChatMessages(1);
|
||||||
}
|
}
|
||||||
} else if (response.code() == 304 && !isFromTheFuture) {
|
} else if (response.code() == 304 && !isFromTheFuture) {
|
||||||
if (isFirstMessagesProcessing) {
|
if (isFirstMessagesProcessing) {
|
||||||
cancelNotificationsForCurrentConversation();
|
cancelNotificationsForCurrentConversation();
|
||||||
|
|
||||||
isFirstMessagesProcessing = false;
|
isFirstMessagesProcessing = false;
|
||||||
if (loadingProgressBar != null) {
|
if (loadingProgressBar != null) {
|
||||||
loadingProgressBar.setVisibility(View.GONE);
|
loadingProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
historyRead = true;
|
historyRead = true;
|
||||||
|
|
||||||
if (!lookingIntoFuture && inChat) {
|
if (!lookingIntoFuture && inChat) {
|
||||||
pullChatMessages(1);
|
pullChatMessages(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user