mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 06:25:14 +01:00
Bug fixes
This commit is contained in:
parent
a484ab0d7f
commit
f759ce5a65
4 changed files with 73 additions and 57 deletions
|
@ -82,7 +82,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 22
|
||||
versionCode 468
|
||||
versionCode 469
|
||||
versionName "2.6.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -687,17 +687,21 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
protected void processNewDifferenceParams(int seq, int pts, int date, int pts_count) {
|
||||
FileLog.e("tmessages", "processNewDifferenceParams seq = " + seq + " pts = " + pts + " date = " + date + " pts_count = " + pts_count);
|
||||
if (pts != -1) {
|
||||
if (MessagesStorage.lastPtsValue + pts_count == pts) {
|
||||
FileLog.e("tmessages", "APPLY PTS");
|
||||
MessagesStorage.lastPtsValue = pts;
|
||||
MessagesStorage.getInstance().saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
|
||||
} else if (MessagesStorage.lastPtsValue == pts) {
|
||||
} else if (MessagesStorage.lastPtsValue != pts) {
|
||||
if (gettingDifference || updatesStartWaitTimePts == 0 || updatesStartWaitTimePts != 0 && updatesStartWaitTimePts + 1500 > System.currentTimeMillis()) {
|
||||
FileLog.e("tmessages", "ADD UPDATE TO QUEUE pts = " + pts + " pts_count = " + pts_count);
|
||||
if (updatesStartWaitTimePts == 0) {
|
||||
updatesStartWaitTimePts = System.currentTimeMillis();
|
||||
}
|
||||
UserActionUpdatesPts updates = new UserActionUpdatesPts();
|
||||
updates.seq = seq;
|
||||
updates.pts = pts;
|
||||
updates.pts_count = pts_count;
|
||||
updatesQueuePts.add(updates);
|
||||
} else {
|
||||
getDifference();
|
||||
|
@ -706,6 +710,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
if (seq != -1) {
|
||||
if (MessagesStorage.lastSeqValue + 1 == seq) {
|
||||
FileLog.e("tmessages", "APPLY SEQ");
|
||||
MessagesStorage.lastSeqValue = seq;
|
||||
if (date != -1) {
|
||||
MessagesStorage.lastDateValue = date;
|
||||
|
@ -713,6 +718,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue);
|
||||
} else if (MessagesStorage.lastSeqValue != seq) {
|
||||
if (gettingDifference || updatesStartWaitTimeSeq == 0 || updatesStartWaitTimeSeq != 0 && updatesStartWaitTimeSeq + 1500 > System.currentTimeMillis()) {
|
||||
FileLog.e("tmessages", "ADD UPDATE TO QUEUE seq = " + seq);
|
||||
if (updatesStartWaitTimeSeq == 0) {
|
||||
updatesStartWaitTimeSeq = System.currentTimeMillis();
|
||||
}
|
||||
|
|
|
@ -514,11 +514,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
ArrayList<TLRPC.Message> arr = new ArrayList<>();
|
||||
ArrayList<Long> randomIds = new ArrayList<>();
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
HashMap<Long, TLRPC.Message> messagesByRandomIds = new HashMap<>();
|
||||
|
||||
for (int a = 0; a < messages.size(); a++) {
|
||||
MessageObject msgObj = messages.get(a);
|
||||
|
||||
TLRPC.Message newMsg = new TLRPC.TL_message();
|
||||
final TLRPC.Message newMsg = new TLRPC.TL_message();
|
||||
newMsg.flags |= TLRPC.MESSAGE_FLAG_FWD;
|
||||
if (msgObj.isForwarded()) {
|
||||
newMsg.fwd_from_id = msgObj.messageOwner.fwd_from_id;
|
||||
|
@ -541,6 +542,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
newMsg.random_id = getNextRandomId();
|
||||
}
|
||||
randomIds.add(newMsg.random_id);
|
||||
messagesByRandomIds.put(newMsg.random_id, newMsg);
|
||||
ids.add(newMsg.fwd_msg_id);
|
||||
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
|
||||
newMsg.flags |= TLRPC.MESSAGE_FLAG_UNREAD;
|
||||
|
@ -553,7 +555,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
|
||||
putToSendingMessages(newMsg);
|
||||
|
||||
if (a % 100 == 0 || a == messages.size() - 1) {
|
||||
if (arr.size() == 100 || a == messages.size() - 1) {
|
||||
MessagesStorage.getInstance().putMessages(arr, false, true, false, 0);
|
||||
MessagesController.getInstance().updateInterfaceWithMessages(peer, objArr);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
|
||||
|
@ -564,70 +566,78 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
req.random_id = randomIds;
|
||||
req.id = ids;
|
||||
|
||||
/*ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
final ArrayList<TLRPC.Message> newMsgObjArr = arr;
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
if (error == null) {
|
||||
final int oldId = newMsgObj.id;
|
||||
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
|
||||
final String attachPath = newMsgObj.attachPath;
|
||||
|
||||
if (response instanceof TLRPC.messages_StatedMessages) {
|
||||
TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
|
||||
if (!res.messages.isEmpty()) {
|
||||
sentMessages.addAll(res.messages);
|
||||
TLRPC.Message message = res.messages.get(0);
|
||||
newMsgObj.id = message.id;
|
||||
processSentMessage(newMsgObj, message, originalPath);
|
||||
}
|
||||
if (res instanceof TLRPC.TL_messages_statedMessages) {
|
||||
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, -1, res.pts_count);
|
||||
} else if (res instanceof TLRPC.TL_messages_statedMessagesLinks) {
|
||||
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1, res.pts_count);
|
||||
}
|
||||
final TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
|
||||
if (newMsgObjArr.size() != res.messages.size()) {
|
||||
MessagesController.getInstance().getDifference();
|
||||
return;
|
||||
}
|
||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false);
|
||||
MessagesStorage.getInstance().putMessages(sentMessages, true, false, false, 0);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj);
|
||||
processSentMessage(oldId);
|
||||
removeFromSendingMessages(oldId);
|
||||
if (res instanceof TLRPC.TL_messages_statedMessages) {
|
||||
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, -1, res.pts_count);
|
||||
} else if (res instanceof TLRPC.TL_messages_statedMessagesLinks) {
|
||||
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1, res.pts_count);
|
||||
}
|
||||
for (int a = 0; a < res.messages.size(); a++) {
|
||||
TLRPC.Message message = res.messages.get(a);
|
||||
final TLRPC.Message newMsgObj = newMsgObjArr.get(a);
|
||||
if (newMsgObj == null) {
|
||||
continue;
|
||||
}
|
||||
final int oldId = newMsgObj.id;
|
||||
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
|
||||
sentMessages.add(message);
|
||||
newMsgObj.id = message.id;
|
||||
processSentMessage(newMsgObj, message, null);
|
||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false);
|
||||
MessagesStorage.getInstance().putMessages(sentMessages, true, false, false, 0);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj);
|
||||
processSentMessage(oldId);
|
||||
removeFromSendingMessages(oldId);
|
||||
}
|
||||
});
|
||||
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||
stopVideoService(newMsgObj.attachPath);
|
||||
}
|
||||
});
|
||||
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||
stopVideoService(attachPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id);
|
||||
processSentMessage(newMsgObj.id);
|
||||
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||
stopVideoService(newMsgObj.attachPath);
|
||||
for (final TLRPC.Message newMsgObj : newMsgObjArr) {
|
||||
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id);
|
||||
processSentMessage(newMsgObj.id);
|
||||
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||
stopVideoService(newMsgObj.attachPath);
|
||||
}
|
||||
removeFromSendingMessages(newMsgObj.id);
|
||||
}
|
||||
removeFromSendingMessages(newMsgObj.id);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassCanCompress, ConnectionsManager.DEFAULT_DATACENTER_ID);
|
||||
*/
|
||||
|
||||
if (a != messages.size() - 1) {
|
||||
objArr = new ArrayList<>();
|
||||
arr = new ArrayList<>();
|
||||
randomIds = new ArrayList<>();
|
||||
ids = new ArrayList<>();
|
||||
messagesByRandomIds = new HashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1895,10 +1895,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (arrayList == null || arrayList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (MessageObject object : arrayList) {
|
||||
if (!fromMyName) {
|
||||
SendMessagesHelper.getInstance().sendMessage(object, dialog_id);
|
||||
} else {
|
||||
if (!fromMyName) {
|
||||
SendMessagesHelper.getInstance().sendMessage(arrayList, dialog_id);
|
||||
} else {
|
||||
for (MessageObject object : arrayList) {
|
||||
SendMessagesHelper.getInstance().processForwardFromMyName(object, dialog_id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue