Added chat full photo cache reset

Closes #959
This commit is contained in:
Igor Zhukov 2015-11-25 18:36:22 +03:00
parent 0b15fa8f4b
commit 0859be8ab7

View File

@ -1251,6 +1251,29 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
});
$rootScope.$on('chat_update', function (e, chatID) {
var fullChat = chatsFull[chatID];
var chat = AppChatsManager.getChat(chatID);
if (!chat.photo || !fullChat) {
return;
}
var emptyPhoto = chat.photo == 'chatPhotoEmpty';
if (emptyPhoto != (fullChat.chat_photo._ == 'photoEmpty')) {
delete chatsFull[chatID];
$rootScope.$broadcast('chat_full_update', chatID);
return;
}
if (emptyPhoto) {
return;
}
var smallUserpic = chat.photo.photo_small;
var smallPhotoSize = AppPhotosManager.choosePhotoSize(fullChat.chat_photo, 0, 0);
if (!angular.equals(smallUserpic, smallPhotoSize.location)) {
delete chatsFull[chatID];
$rootScope.$broadcast('chat_full_update', chatID);
}
});
return {
getPeerBots: getPeerBots,
getProfile: getProfile,