Browse Source

Fixed empty message handling

master
Igor Zhukov 9 years ago
parent
commit
2115a81a4f
  1. 6
      app/js/controllers.js
  2. 12
      app/js/messages_manager.js

6
app/js/controllers.js

@ -701,7 +701,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -701,7 +701,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
for (i = 0; i < len; i++) {
dialog = indexesToDialogs[indexes[i]];
$scope.dialogs.unshift(
AppMessagesManager.wrapForDialog(dialog.top_message, dialog.unread_count)
AppMessagesManager.wrapForDialog(dialog.top_message, dialog)
);
}
@ -879,7 +879,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -879,7 +879,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (dialogsResult.dialogs.length) {
angular.forEach(dialogsResult.dialogs, function (dialog) {
var wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog.unread_count);
var wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog);
if (!searchMessages) {
peersInDialogs[dialog.peerID] = true;
}
@ -930,7 +930,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -930,7 +930,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var dialogsList = searchMessages ? $scope.foundMessages : $scope.dialogs;
angular.forEach(dialogsResult.dialogs, function (dialog) {
var wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog.unread_count);
var wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog);
if (!searchMessages) {
peersInDialogs[dialog.peerID] = true;
}

12
app/js/messages_manager.js

@ -390,7 +390,7 @@ angular.module('myApp.services') @@ -390,7 +390,7 @@ angular.module('myApp.services')
var fullMsgIDModulus = 4294967296;
function getFullMessageID (msgID, channelID) {
if (!channelID || msgID < 0) {
if (!channelID || msgID <= 0) {
return msgID;
}
msgID = getMessageLocalID(msgID);
@ -1675,8 +1675,9 @@ angular.module('myApp.services') @@ -1675,8 +1675,9 @@ angular.module('myApp.services')
return message.from_id;
}
function wrapForDialog (msgID, unreadCount) {
var useCache = unreadCount != -1;
function wrapForDialog (msgID, dialog) {
var useCache = dialog === undefined;
var unreadCount = dialog && dialog.unread_count;
if (useCache && messagesForDialogs[msgID] !== undefined) {
return messagesForDialogs[msgID];
@ -1685,8 +1686,13 @@ angular.module('myApp.services') @@ -1685,8 +1686,13 @@ angular.module('myApp.services')
var message = angular.copy(messagesStorage[msgID]);
if (!message || !message.to_id) {
if (dialog && dialog.peerID) {
message = {_: 'message', to_id: AppPeersManager.getOutputPeer(dialog.peerID), deleted: true, date: tsNow(true)};
message.deleted = true;
} else {
return message;
}
}
message.peerID = getMessagePeer(message);
message.peerData = AppPeersManager.getPeer(message.peerID);

Loading…
Cancel
Save