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