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

21
app/js/messages_manager.js

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

Loading…
Cancel
Save