Fixed pinned messages bugs
This commit is contained in:
parent
1f080a96fc
commit
550f8ae781
@ -790,15 +790,20 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.$on('dialog_top', function (e, dialog) {
|
$scope.$on('dialog_top', function (e, dialog) {
|
||||||
var curDialog, i
|
var curDialog, i, wrappedDialog
|
||||||
for (i = 0; i < $scope.dialogs.length; i++) {
|
var len = $scope.dialogs.length
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
curDialog = $scope.dialogs[i]
|
curDialog = $scope.dialogs[i]
|
||||||
if (curDialog.peerID == dialog.peerID) {
|
if (curDialog.peerID == dialog.peerID) {
|
||||||
var wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog)
|
wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog)
|
||||||
$scope.dialogs.splice(i, 1, wrappedDialog)
|
$scope.dialogs.splice(i, 1, wrappedDialog)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sortDialogs()
|
||||||
|
if (wrappedDialog == $scope.dialogs[len - 1]) {
|
||||||
|
$scope.dialogs.splice(len - 1, 1)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
$scope.$on('dialog_flush', function (e, update) {
|
$scope.$on('dialog_flush', function (e, update) {
|
||||||
var curDialog, i
|
var curDialog, i
|
||||||
@ -1065,9 +1070,13 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
|
|
||||||
if (searchMessages) {
|
if (searchMessages) {
|
||||||
wrappedDialog.unreadCount = -1
|
wrappedDialog.unreadCount = -1
|
||||||
|
} else {
|
||||||
|
if (peersInDialogs[dialog.peerID]) {
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
peersInDialogs[dialog.peerID] = true
|
peersInDialogs[dialog.peerID] = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (searchMessages &&
|
if (searchMessages &&
|
||||||
$scope.searchPeer) {
|
$scope.searchPeer) {
|
||||||
|
@ -219,11 +219,14 @@ angular.module('myApp.services')
|
|||||||
var offsetID = 0
|
var offsetID = 0
|
||||||
var offsetPeerID = 0
|
var offsetPeerID = 0
|
||||||
var offsetIndex = 0
|
var offsetIndex = 0
|
||||||
|
var flags = 0
|
||||||
if (dialogsOffsetDate) {
|
if (dialogsOffsetDate) {
|
||||||
offsetDate = dialogsOffsetDate + ServerTimeManager.serverTimeOffset
|
offsetDate = dialogsOffsetDate + ServerTimeManager.serverTimeOffset
|
||||||
offsetIndex = dialogsOffsetDate * 0x10000
|
offsetIndex = dialogsOffsetDate * 0x10000
|
||||||
|
flags |= 1
|
||||||
}
|
}
|
||||||
return MtpApiManager.invokeApi('messages.getDialogs', {
|
return MtpApiManager.invokeApi('messages.getDialogs', {
|
||||||
|
flags: flags,
|
||||||
offset_date: offsetDate,
|
offset_date: offsetDate,
|
||||||
offset_id: AppMessagesIDsManager.getMessageLocalID(offsetID),
|
offset_id: AppMessagesIDsManager.getMessageLocalID(offsetID),
|
||||||
offset_peer: AppPeersManager.getInputPeerByID(offsetPeerID),
|
offset_peer: AppPeersManager.getInputPeerByID(offsetPeerID),
|
||||||
@ -284,15 +287,22 @@ angular.module('myApp.services')
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pushDialogToStorage (dialog, offsetDate) {
|
function pushDialogToStorage (dialog, offsetDate) {
|
||||||
if (offsetDate && (!dialogsOffsetDate || offsetDate < dialogsOffsetDate)) {
|
|
||||||
dialogsOffsetDate = offsetDate
|
|
||||||
}
|
|
||||||
var dialogs = dialogsStorage.dialogs
|
var dialogs = dialogsStorage.dialogs
|
||||||
var pos = getDialogByPeerID(dialog.peerID)[1]
|
var pos = getDialogByPeerID(dialog.peerID)[1]
|
||||||
if (pos !== undefined) {
|
if (pos !== undefined) {
|
||||||
dialogs.splice(pos, 1)
|
dialogs.splice(pos, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (offsetDate &&
|
||||||
|
!dialog.pFlags.pinned &&
|
||||||
|
(!dialogsOffsetDate || offsetDate < dialogsOffsetDate)) {
|
||||||
|
if (pos !== undefined) {
|
||||||
|
// So the dialog jumped to the last position
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
dialogsOffsetDate = offsetDate
|
||||||
|
}
|
||||||
|
|
||||||
var index = dialog.index
|
var index = dialog.index
|
||||||
var i
|
var i
|
||||||
var len = dialogs.length
|
var len = dialogs.length
|
||||||
@ -301,7 +311,8 @@ angular.module('myApp.services')
|
|||||||
}
|
}
|
||||||
else if (index >= dialogs[0].index) {
|
else if (index >= dialogs[0].index) {
|
||||||
dialogs.unshift(dialog)
|
dialogs.unshift(dialog)
|
||||||
}else {
|
}
|
||||||
|
else {
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (index > dialogs[i].index) {
|
if (index > dialogs[i].index) {
|
||||||
dialogs.splice(i, 0, dialog)
|
dialogs.splice(i, 0, dialog)
|
||||||
@ -3462,17 +3473,18 @@ angular.module('myApp.services')
|
|||||||
var updatedDialogs = {}
|
var updatedDialogs = {}
|
||||||
var hasUpdated = false
|
var hasUpdated = false
|
||||||
angular.forEach(dialogsResult.dialogs, function (dialog) {
|
angular.forEach(dialogsResult.dialogs, function (dialog) {
|
||||||
|
var peerID = AppPeersManager.getPeerID(dialog.peer)
|
||||||
if (dialog.top_message) {
|
if (dialog.top_message) {
|
||||||
var wasBefore = getDialogByPeerID(dialog.peerID).length > 0
|
var wasBefore = getDialogByPeerID(peerID).length > 0
|
||||||
saveConversation(dialog)
|
saveConversation(dialog)
|
||||||
if (wasBefore) {
|
if (wasBefore) {
|
||||||
|
clearDialogCache(dialog.top_message)
|
||||||
$rootScope.$broadcast('dialog_top', dialog)
|
$rootScope.$broadcast('dialog_top', dialog)
|
||||||
} else {
|
} else {
|
||||||
updatedDialogs[dialog.peerID] = dialog
|
updatedDialogs[peerID] = dialog
|
||||||
hasUpdated = true
|
hasUpdated = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var peerID = AppPeersManager.getPeerID(dialog.peer)
|
|
||||||
var foundDialog = getDialogByPeerID(peerID)
|
var foundDialog = getDialogByPeerID(peerID)
|
||||||
if (foundDialog.length) {
|
if (foundDialog.length) {
|
||||||
dialogsStorage.dialogs.splice(foundDialog[1], 1)
|
dialogsStorage.dialogs.splice(foundDialog[1], 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user