Browse Source

Fixed conversation position after draft clear

master
Igor Zhukov 8 years ago
parent
commit
439ee9ecad
  1. 15
      app/js/controllers.js
  2. 21
      app/js/messages_manager.js

15
app/js/controllers.js

@ -736,9 +736,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -736,9 +736,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
)
})
$scope.dialogs.sort(function (d1, d2) {
return d2.index - d1.index
})
sortDialogs()
if (newPeer) {
delete $scope.isEmpty.dialogs
@ -757,6 +755,12 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -757,6 +755,12 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
}
function sortDialogs() {
$scope.dialogs.sort(function (d1, d2) {
return d2.index - d1.index
})
}
$scope.$on('dialog_top', function (e, dialog) {
var curDialog, i
for (i = 0; i < $scope.dialogs.length; i++) {
@ -791,10 +795,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -791,10 +795,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (draftUpdate.index) {
curDialog.index = draftUpdate.index
}
if (i > 0 && draftUpdate.draft) {
$scope.dialogs.splice(i, 1)
$scope.dialogs.unshift(curDialog)
}
sortDialogs();
break
}
}

21
app/js/messages_manager.js

@ -3219,15 +3219,26 @@ angular.module('myApp.services') @@ -3219,15 +3219,26 @@ angular.module('myApp.services')
var dialog = getDialogByPeerID(peerID)[0]
if (dialog) {
var newIndex
if (dialog && draft && draft.date) {
newIndex = dialog.index = generateDialogIndex(draft.date)
pushDialogToStorage(dialog)
var topDate
if (draft && draft.date) {
topDate = draft.date
} else {
var channelID = AppPeersManager.isChannel(peerID) ? -peerID : 0
var topDate = getMessage(dialog.top_message).date
if (channelID) {
var channel = AppChatsManager.getChat(channelID)
if (!topDate || channel.date && channel.date > topDate) {
topDate = channel.date
}
}
}
dialog.index = generateDialogIndex(topDate)
pushDialogToStorage(dialog)
$rootScope.$broadcast('dialog_draft', {
peerID: peerID,
draft: draft,
index: dialog && dialog.index
index: dialog.index
})
}
})

Loading…
Cancel
Save