Browse Source

Fixed drafts position in conversations

master
Igor Zhukov 8 years ago
parent
commit
0e531b27a9
  1. 5
      app/js/controllers.js
  2. 25
      app/js/messages_manager.js

5
app/js/controllers.js

@ -782,12 +782,15 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -782,12 +782,15 @@ angular.module('myApp.controllers', ['myApp.i18n'])
deleteDialog(dialog.peerID)
})
$scope.$on('draft_updated', function (e, draftUpdate) {
$scope.$on('dialog_draft', function (e, draftUpdate) {
var curDialog, i
for (i = 0; i < $scope.dialogs.length; i++) {
curDialog = $scope.dialogs[i]
if (curDialog.peerID == draftUpdate.peerID) {
curDialog.draft = draftUpdate.draft
if (draftUpdate.index) {
curDialog.index = draftUpdate.index
}
if (i > 0 && draftUpdate.draft) {
$scope.dialogs.splice(i, 1)
$scope.dialogs.unshift(curDialog)

25
app/js/messages_manager.js

@ -3156,23 +3156,6 @@ angular.module('myApp.services') @@ -3156,23 +3156,6 @@ angular.module('myApp.services')
})
}
break
case 'updateDraftMessage':
var peerID = AppPeersManager.getPeerID(update.peer)
var draft = DraftsManager.saveDraft(peerID, update.draft)
var dialog = getDialogByPeerID(peerID)[0]
if (dialog) {
if (dialog && draft && draft.date) {
dialog.index = generateDialogIndex(draft.date)
pushDialogToStorage(dialog)
}
$rootScope.$broadcast('dialog_draft', {
peerID: peerID,
draft: draft
})
}
break
}
})
@ -3236,10 +3219,16 @@ angular.module('myApp.services') @@ -3236,10 +3219,16 @@ angular.module('myApp.services')
var dialog = getDialogByPeerID(peerID)[0]
if (dialog) {
var newIndex
if (dialog && draft && draft.date) {
dialog.index = generateDialogIndex(draft.date)
newIndex = dialog.index = generateDialogIndex(draft.date)
pushDialogToStorage(dialog)
}
$rootScope.$broadcast('dialog_draft', {
peerID: peerID,
draft: draft,
index: dialog && dialog.index
})
}
})

Loading…
Cancel
Save