From f38f15f4a77c9d5188e4258f4c3c7e5eea776d73 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sat, 11 Jan 2014 10:30:29 +0400 Subject: [PATCH] Fixed notification empty group photo, mtproto baseDcID bug, empty thumb bug --- app/index.html | 6 +++--- app/js/directives.js | 3 +-- app/js/lib/mtproto.js | 25 +++++++++++++++---------- app/js/services.js | 2 +- app/partials/dialog.html | 2 +- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/index.html b/app/index.html index 07eacfac..5f69ec50 100644 --- a/app/index.html +++ b/app/index.html @@ -32,14 +32,14 @@ - + - + - + diff --git a/app/js/directives.js b/app/js/directives.js index d99ec109..9b778576 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -331,8 +331,7 @@ angular.module('myApp.directives', ['myApp.filters']) function link (scope, element, attrs) { scope.$watch('thumb.location', function (newVal) { - if (!scope.thumb) dLog(222, scope); - if (!scope.thumb.location) { + if (!scope.thumb || !scope.thumb.location) { element.attr('src', scope.thumb.placeholder || ''); return; } diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index 0b029e9b..75315d8b 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -2117,14 +2117,23 @@ factory('MtpApiManager', function (AppConfigManager, MtpAuthorizer, MtpNetworker }; function mtpInvokeApi (method, params, options) { - var deferred = $q.defer(); - options = options || {}; - var dcID = options.dcID || baseDcID || 1; + + var deferred = $q.defer(), + dcID, + networkerPromise; + + if (dcID = options.dcID) { + networkerPromise = mtpGetNetworker(dcID); + } else { + networkerPromise = AppConfigManager.get('dc').then(function (baseDcID) { + return mtpGetNetworker(dcID = baseDcID || 1); + }); + } var cachedNetworker; - mtpGetNetworker(dcID).then(function (networker) { + networkerPromise.then(function (networker) { return (cachedNetworker = networker).wrapApiCall(method, params, options).then( function (result) { deferred.resolve(result); @@ -2175,13 +2184,9 @@ factory('MtpApiManager', function (AppConfigManager, MtpAuthorizer, MtpNetworker }; function mtpGetUserID () { - var deferred = $q.defer(); - - AppConfigManager.get('user_auth').then(function (auth) { - deferred.resolve(auth.id || 0); + return AppConfigManager.get('user_auth').then(function (auth) { + return auth.id || 0; }); - - return deferred.promise; } return { diff --git a/app/js/services.js b/app/js/services.js index 709f7224..0eaee69c 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -1013,7 +1013,7 @@ angular.module('myApp.services', []) notification.message = message.message; - notificationPhoto = AppChatsManager.getChatPhoto(-peerID); + notificationPhoto = AppChatsManager.getChatPhoto(-peerID, 'Chat'); peerString = AppChatsManager.getChatString(-peerID); } diff --git a/app/partials/dialog.html b/app/partials/dialog.html index e81014e9..a259d300 100644 --- a/app/partials/dialog.html +++ b/app/partials/dialog.html @@ -32,7 +32,7 @@ Photo - Video + Video Document