Improved read messages
This commit is contained in:
parent
1d0709bcf6
commit
694584ec9f
@ -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')
|
||||
function handleNewDialogs () {
|
||||
$timeout.cancel(newDialogsHandlePromise)
|
||||
newDialogsHandlePromise = false
|
||||
angular.forEach(newDialogsToHandle, function (dialog) {
|
||||
pushDialogToStorage(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')
|
||||
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,23 +2983,11 @@ angular.module('myApp.services')
|
||||
}
|
||||
}
|
||||
|
||||
var foundDialog = getDialogByPeerID(peerID)
|
||||
var dialog
|
||||
var inboxUnread = !message.pFlags.out && message.pFlags.unread
|
||||
|
||||
if (foundDialog.length) {
|
||||
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
|
||||
}
|
||||
var dialog = foundDialog[0]
|
||||
dialog.top_message = message.mid
|
||||
if (inboxUnread) {
|
||||
dialog.unread_count++
|
||||
}
|
||||
dialog.index = generateDialogIndex(message.date)
|
||||
|
||||
@ -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')
|
||||
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
|
||||
|
@ -70,8 +70,9 @@
|
||||
<div class="md_modal_iconed_section_wrap md_modal_iconed_section_link">
|
||||
<i class="md_modal_section_icon md_modal_section_icon_more"></i>
|
||||
|
||||
<div class="md_modal_section_link_wrap">
|
||||
<a class="md_modal_section_link" ng-click="flushHistory(true)" my-i18n="group_modal_menu_clear_history"></a>
|
||||
<div class="md_modal_section_link_wrap" ng-switch="chatFull.chat.pFlags.left || chatFull.chat.pFlags.kicked || chatFull.chat._ == 'chatForbidden'">
|
||||
<a ng-switch-when="true" class="md_modal_section_link" ng-click="flushHistory(false)" my-i18n="group_modal_menu_delete_group"></a>
|
||||
<a ng-switch-default class="md_modal_section_link" ng-click="flushHistory(true)" my-i18n="group_modal_menu_clear_history"></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user