|
|
@ -1154,7 +1154,7 @@ angular.module('myApp.services') |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function saveMessages (apiMessages) { |
|
|
|
function saveMessages (apiMessages, edited) { |
|
|
|
angular.forEach(apiMessages, function (apiMessage) { |
|
|
|
angular.forEach(apiMessages, function (apiMessage) { |
|
|
|
if (apiMessage.pFlags === undefined) { |
|
|
|
if (apiMessage.pFlags === undefined) { |
|
|
|
apiMessage.pFlags = {}; |
|
|
|
apiMessage.pFlags = {}; |
|
|
@ -1176,13 +1176,10 @@ angular.module('myApp.services') |
|
|
|
|
|
|
|
|
|
|
|
var mid = getFullMessageID(apiMessage.id, channelID); |
|
|
|
var mid = getFullMessageID(apiMessage.id, channelID); |
|
|
|
apiMessage.mid = mid; |
|
|
|
apiMessage.mid = mid; |
|
|
|
messagesStorage[mid] = apiMessage; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (channelID && !apiMessage.pFlags.out) { |
|
|
|
if (channelID && !apiMessage.pFlags.out) { |
|
|
|
var dialog = getDialogByPeerID(toPeerID)[0]; |
|
|
|
var dialog = getDialogByPeerID(toPeerID)[0]; |
|
|
|
apiMessage.pFlags.unread = dialog ? mid > dialog.read_inbox_max_id : true; |
|
|
|
apiMessage.pFlags.unread = dialog ? mid > dialog.read_inbox_max_id : true; |
|
|
|
} else { |
|
|
|
|
|
|
|
apiMessage.pFlags.unread = apiMessage.flags & 1 ? true : false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (apiMessage.reply_to_msg_id) { |
|
|
|
if (apiMessage.reply_to_msg_id) { |
|
|
@ -1292,6 +1289,10 @@ angular.module('myApp.services') |
|
|
|
var apiEntities = apiMessage.entities || []; |
|
|
|
var apiEntities = apiMessage.entities || []; |
|
|
|
apiMessage.totalEntities = RichTextProcessor.mergeEntities(myEntities, apiEntities, !apiMessage.pending); |
|
|
|
apiMessage.totalEntities = RichTextProcessor.mergeEntities(myEntities, apiEntities, !apiMessage.pending); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!edited) { |
|
|
|
|
|
|
|
messagesStorage[mid] = apiMessage; |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2653,12 +2654,11 @@ angular.module('myApp.services') |
|
|
|
case 'updateNewChannelMessage': |
|
|
|
case 'updateNewChannelMessage': |
|
|
|
var message = update.message, |
|
|
|
var message = update.message, |
|
|
|
peerID = getMessagePeer(message), |
|
|
|
peerID = getMessagePeer(message), |
|
|
|
historyStorage = historiesStorage[peerID], |
|
|
|
historyStorage = historiesStorage[peerID]; |
|
|
|
messageForMe = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (update._ == 'updateNewChannelMessage') { |
|
|
|
if (update._ == 'updateNewChannelMessage') { |
|
|
|
if (!AppChatsManager.isMegagroup(-peerID) && |
|
|
|
if (!AppChatsManager.isMegagroup(-peerID) && |
|
|
|
!(message.flags & 16 || message.flags & 2 || (message.flags & 256) == 0)) { |
|
|
|
!(message.pFlags.out || message.pFlags.mention || message.pFlags.post)) { |
|
|
|
// we don't support not important messages in channels yet
|
|
|
|
// we don't support not important messages in channels yet
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -2778,6 +2778,34 @@ angular.module('myApp.services') |
|
|
|
incrementMaxSeenID(message.id); |
|
|
|
incrementMaxSeenID(message.id); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateEditMessage': |
|
|
|
|
|
|
|
case 'updateEditChannelMessage': |
|
|
|
|
|
|
|
var message = update.message, |
|
|
|
|
|
|
|
peerID = getMessagePeer(message), |
|
|
|
|
|
|
|
historyStorage = historiesStorage[peerID]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveMessages([message], true); |
|
|
|
|
|
|
|
var mid = message.mid; |
|
|
|
|
|
|
|
if (messagesStorage[mid] !== undefined) { |
|
|
|
|
|
|
|
safeReplaceObject(messagesStorage[mid], message); |
|
|
|
|
|
|
|
messagesStorage[mid] = message; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (messagesForHistory[mid] !== undefined) { |
|
|
|
|
|
|
|
var wasForHistory = messagesForHistory[mid]; |
|
|
|
|
|
|
|
delete messagesForHistory[mid]; |
|
|
|
|
|
|
|
var newForHistory = wrapForHistory(message); |
|
|
|
|
|
|
|
safeReplaceObject(wasForHistory, newForHistory); |
|
|
|
|
|
|
|
messagesForHistory[mid] = newForHistory; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// if (messagesForDialogs[mid] !== undefined) {
|
|
|
|
|
|
|
|
// var wasForHistory = messagesForDialogs[mid];
|
|
|
|
|
|
|
|
// delete messagesForDialogs[mid];
|
|
|
|
|
|
|
|
// var newForHistory = wrapForHistory(message);
|
|
|
|
|
|
|
|
// safeReplaceObject(wasForHistory, newForHistory);
|
|
|
|
|
|
|
|
// messagesForDialogs[mid] = newForHistory;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'updateReadHistoryInbox': |
|
|
|
case 'updateReadHistoryInbox': |
|
|
|
case 'updateReadHistoryOutbox': |
|
|
|
case 'updateReadHistoryOutbox': |
|
|
|
case 'updateReadChannelInbox': |
|
|
|
case 'updateReadChannelInbox': |
|
|
|