|
|
@ -1515,7 +1515,9 @@ angular.module('myApp.services') |
|
|
|
random_id: randomIDS, |
|
|
|
random_id: randomIDS, |
|
|
|
id: updates.id |
|
|
|
id: updates.id |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
_: isChannel ? 'updateNewChannelMessage' : 'updateNewMessage', |
|
|
|
_: isChannel |
|
|
|
|
|
|
|
? 'updateNewChannelMessage' |
|
|
|
|
|
|
|
: 'updateNewMessage', |
|
|
|
message: message, |
|
|
|
message: message, |
|
|
|
pts: updates.pts, |
|
|
|
pts: updates.pts, |
|
|
|
pts_count: updates.pts_count |
|
|
|
pts_count: updates.pts_count |
|
|
@ -2846,9 +2848,21 @@ angular.module('myApp.services') |
|
|
|
function handleNewDialogs () { |
|
|
|
function handleNewDialogs () { |
|
|
|
$timeout.cancel(newDialogsHandlePromise) |
|
|
|
$timeout.cancel(newDialogsHandlePromise) |
|
|
|
newDialogsHandlePromise = false |
|
|
|
newDialogsHandlePromise = false |
|
|
|
angular.forEach(newDialogsToHandle, function (dialog) { |
|
|
|
var newMaxSeenID = 0 |
|
|
|
|
|
|
|
angular.forEach(newDialogsToHandle, function (dialog, peerID) { |
|
|
|
|
|
|
|
if (dialog.reload) { |
|
|
|
|
|
|
|
reloadConversation(peerID) |
|
|
|
|
|
|
|
delete newDialogsToHandle[peerID] |
|
|
|
|
|
|
|
} else { |
|
|
|
pushDialogToStorage(dialog) |
|
|
|
pushDialogToStorage(dialog) |
|
|
|
|
|
|
|
if (!AppPeersManager.isChannel(peerID)) { |
|
|
|
|
|
|
|
newMaxSeenID = Math.max(newMaxSeenID, dialog.top_message || 0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
if (newMaxSeenID !== false) { |
|
|
|
|
|
|
|
incrementMaxSeenID(newMaxSeenID) |
|
|
|
|
|
|
|
} |
|
|
|
$rootScope.$broadcast('dialogs_multiupdate', newDialogsToHandle) |
|
|
|
$rootScope.$broadcast('dialogs_multiupdate', newDialogsToHandle) |
|
|
|
newDialogsToHandle = {} |
|
|
|
newDialogsToHandle = {} |
|
|
|
} |
|
|
|
} |
|
|
@ -2898,6 +2912,15 @@ angular.module('myApp.services') |
|
|
|
var message = update.message |
|
|
|
var message = update.message |
|
|
|
var peerID = getMessagePeer(message) |
|
|
|
var peerID = getMessagePeer(message) |
|
|
|
var historyStorage = historiesStorage[peerID] |
|
|
|
var historyStorage = historiesStorage[peerID] |
|
|
|
|
|
|
|
var foundDialog = getDialogByPeerID(peerID) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!foundDialog.length) { |
|
|
|
|
|
|
|
newDialogsToHandle[peerID] = {reload: true} |
|
|
|
|
|
|
|
if (!newDialogsHandlePromise) { |
|
|
|
|
|
|
|
newDialogsHandlePromise = $timeout(handleNewDialogs, 0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (update._ == 'updateNewChannelMessage') { |
|
|
|
if (update._ == 'updateNewChannelMessage') { |
|
|
|
var chat = AppChatsManager.getChat(-peerID) |
|
|
|
var chat = AppChatsManager.getChat(-peerID) |
|
|
@ -2960,24 +2983,12 @@ angular.module('myApp.services') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var foundDialog = getDialogByPeerID(peerID) |
|
|
|
|
|
|
|
var dialog |
|
|
|
|
|
|
|
var inboxUnread = !message.pFlags.out && message.pFlags.unread |
|
|
|
var inboxUnread = !message.pFlags.out && message.pFlags.unread |
|
|
|
|
|
|
|
var dialog = foundDialog[0] |
|
|
|
if (foundDialog.length) { |
|
|
|
|
|
|
|
dialog = foundDialog[0] |
|
|
|
|
|
|
|
dialog.top_message = message.mid |
|
|
|
dialog.top_message = message.mid |
|
|
|
if (inboxUnread) { |
|
|
|
if (inboxUnread) { |
|
|
|
dialog.unread_count++ |
|
|
|
dialog.unread_count++ |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
SearchIndexManager.indexObject(peerID, AppPeersManager.getPeerSearchText(peerID), dialogsIndex) |
|
|
|
|
|
|
|
dialog = { |
|
|
|
|
|
|
|
peerID: peerID, |
|
|
|
|
|
|
|
unread_count: inboxUnread ? 1 : 0, |
|
|
|
|
|
|
|
top_message: message.mid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
dialog.index = generateDialogIndex(message.date) |
|
|
|
dialog.index = generateDialogIndex(message.date) |
|
|
|
|
|
|
|
|
|
|
|
newDialogsToHandle[peerID] = dialog |
|
|
|
newDialogsToHandle[peerID] = dialog |
|
|
@ -3011,10 +3022,6 @@ angular.module('myApp.services') |
|
|
|
notificationsHandlePromise = $timeout(handleNotifications, 1000) |
|
|
|
notificationsHandlePromise = $timeout(handleNotifications, 1000) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!AppPeersManager.isChannel(peerID)) { |
|
|
|
|
|
|
|
incrementMaxSeenID(message.id) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
case 'updateEditMessage': |
|
|
|
case 'updateEditMessage': |
|
|
@ -3325,8 +3332,9 @@ angular.module('myApp.services') |
|
|
|
var hasUpdated = false |
|
|
|
var hasUpdated = false |
|
|
|
angular.forEach(dialogsResult.dialogs, function (dialog) { |
|
|
|
angular.forEach(dialogsResult.dialogs, function (dialog) { |
|
|
|
if (dialog.top_message) { |
|
|
|
if (dialog.top_message) { |
|
|
|
|
|
|
|
var wasBefore = getDialogByPeerID(dialog.peerID).length > 0 |
|
|
|
saveConversation(dialog) |
|
|
|
saveConversation(dialog) |
|
|
|
if (getDialogByPeerID(dialog.peerID).length) { |
|
|
|
if (wasBefore) { |
|
|
|
$rootScope.$broadcast('dialog_top', dialog) |
|
|
|
$rootScope.$broadcast('dialog_top', dialog) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
updatedDialogs[dialog.peerID] = dialog |
|
|
|
updatedDialogs[dialog.peerID] = dialog |
|
|
|