Browse Source

Fixed empty message handling

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

6
app/js/controllers.js

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

14
app/js/messages_manager.js

@ -390,7 +390,7 @@ angular.module('myApp.services')
var fullMsgIDModulus = 4294967296; var fullMsgIDModulus = 4294967296;
function getFullMessageID (msgID, channelID) { function getFullMessageID (msgID, channelID) {
if (!channelID || msgID < 0) { if (!channelID || msgID <= 0) {
return msgID; return msgID;
} }
msgID = getMessageLocalID(msgID); msgID = getMessageLocalID(msgID);
@ -1675,8 +1675,9 @@ angular.module('myApp.services')
return message.from_id; return message.from_id;
} }
function wrapForDialog (msgID, unreadCount) { function wrapForDialog (msgID, dialog) {
var useCache = unreadCount != -1; var useCache = dialog === undefined;
var unreadCount = dialog && dialog.unread_count;
if (useCache && messagesForDialogs[msgID] !== undefined) { if (useCache && messagesForDialogs[msgID] !== undefined) {
return messagesForDialogs[msgID]; return messagesForDialogs[msgID];
@ -1685,7 +1686,12 @@ angular.module('myApp.services')
var message = angular.copy(messagesStorage[msgID]); var message = angular.copy(messagesStorage[msgID]);
if (!message || !message.to_id) { if (!message || !message.to_id) {
return message; 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.peerID = getMessagePeer(message);

Loading…
Cancel
Save