Browse Source

Improved dialogs ordering

master
Igor Zhukov 9 years ago
parent
commit
7c8a6c15e7
  1. 37
      app/js/controllers.js
  2. 21
      app/js/messages_manager.js

37
app/js/controllers.js

@ -709,18 +709,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
return false return false
} }
var indexes = [] var i
var indexesToDialogs = {} var dialog
angular.forEach(dialogsUpdated, function (dialog, peerID) { var newPeer = false
if ($scope.noUsers && peerID > 0) {
return
}
indexesToDialogs[dialog.index] = dialog
indexes.push(dialog.index)
})
indexes.sort()
var i, dialog
var len = $scope.dialogs.length var len = $scope.dialogs.length
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
dialog = $scope.dialogs[i] dialog = $scope.dialogs[i]
@ -731,18 +722,26 @@ angular.module('myApp.controllers', ['myApp.i18n'])
AppMessagesManager.clearDialogCache(dialog.mid) AppMessagesManager.clearDialogCache(dialog.mid)
} }
} }
len = indexes.length
for (i = 0; i < len; i++) { angular.forEach(dialogsUpdated, function (dialog, peerID) {
dialog = indexesToDialogs[indexes[i]] if ($scope.noUsers && peerID > 0) {
return
}
if (!peersInDialogs[peerID]) {
peersInDialogs[peerID] = true
newPeer = true
}
$scope.dialogs.unshift( $scope.dialogs.unshift(
AppMessagesManager.wrapForDialog(dialog.top_message, dialog) AppMessagesManager.wrapForDialog(dialog.top_message, dialog)
) )
} })
delete $scope.isEmpty.dialogs $scope.dialogs.sort(function (d1, d2) {
return d2.index - d1.index
})
if (!peersInDialogs[dialog.peerID]) { if (newPeer) {
peersInDialogs[dialog.peerID] = true delete $scope.isEmpty.dialogs
if (contactsShown) { if (contactsShown) {
showMoreConversations() showMoreConversations()
} }

21
app/js/messages_manager.js

@ -1297,8 +1297,8 @@ angular.module('myApp.services')
var replyToMsgID = options.replyToMsgID var replyToMsgID = options.replyToMsgID
var isChannel = AppPeersManager.isChannel(peerID) var isChannel = AppPeersManager.isChannel(peerID)
var isMegagroup = isChannel && AppPeersManager.isMegagroup(peerID) var isMegagroup = isChannel && AppPeersManager.isMegagroup(peerID)
var asChannel = isChannel && !isMegagroup ? true : false, var asChannel = isChannel && !isMegagroup ? true : false
message var message
if (historyStorage === undefined) { if (historyStorage === undefined) {
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []} historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []}
@ -1318,6 +1318,7 @@ angular.module('myApp.services')
} }
if (asChannel) { if (asChannel) {
fromID = 0 fromID = 0
pFlags.post = true
} else { } else {
flags |= 256 flags |= 256
} }
@ -1463,8 +1464,8 @@ angular.module('myApp.services')
var replyToMsgID = options.replyToMsgID var replyToMsgID = options.replyToMsgID
var isChannel = AppPeersManager.isChannel(peerID) var isChannel = AppPeersManager.isChannel(peerID)
var isMegagroup = isChannel && AppPeersManager.isMegagroup(peerID) var isMegagroup = isChannel && AppPeersManager.isMegagroup(peerID)
var asChannel = isChannel && !isMegagroup ? true : false, var asChannel = isChannel && !isMegagroup ? true : false
attachType, apiFileName var attachType, apiFileName
var realFileName var realFileName
if (!options.isMedia) { if (!options.isMedia) {
@ -1504,6 +1505,7 @@ angular.module('myApp.services')
} }
if (asChannel) { if (asChannel) {
fromID = 0 fromID = 0
pFlags.post = true
} else { } else {
flags |= 256 flags |= 256
} }
@ -1730,6 +1732,7 @@ angular.module('myApp.services')
} }
if (asChannel) { if (asChannel) {
fromID = 0 fromID = 0
pFlags.post = true
} else { } else {
flags |= 256 flags |= 256
} }
@ -2019,8 +2022,13 @@ angular.module('myApp.services')
if (!message || !message.to_id) { if (!message || !message.to_id) {
if (dialog && dialog.peerID) { if (dialog && dialog.peerID) {
message = {_: 'message', to_id: AppPeersManager.getOutputPeer(dialog.peerID), deleted: true, date: tsNow(true), pFlags: {}} message = {
message.deleted = true _: 'message',
to_id: AppPeersManager.getOutputPeer(dialog.peerID),
deleted: true,
date: tsNow(true),
pFlags: {}
}
} else { } else {
return message return message
} }
@ -2030,6 +2038,7 @@ angular.module('myApp.services')
message.peerData = AppPeersManager.getPeer(message.peerID) message.peerData = AppPeersManager.getPeer(message.peerID)
message.peerString = AppPeersManager.getPeerString(message.peerID) message.peerString = AppPeersManager.getPeerString(message.peerID)
message.unreadCount = unreadCount message.unreadCount = unreadCount
message.index = dialog && dialog.index || (message.date * 0x10000)
if (message._ == 'messageService' && message.action.user_id) { if (message._ == 'messageService' && message.action.user_id) {
message.action.user = AppUsersManager.getUser(message.action.user_id) message.action.user = AppUsersManager.getUser(message.action.user_id)

Loading…
Cancel
Save