From 4d69ec04c8894dddf41b52ca0530595ebb17ee9e Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 6 Jul 2014 17:53:46 +0400 Subject: [PATCH] Fixed no network on auth Closes #367 --- app/js/lib/mtproto.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index c4a8a3a8..19e6f514 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -198,10 +198,9 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) responseType: 'arraybuffer', transformRequest: null, transformResponse: function (responseBuffer) { - var deserializer = new TLDeserialization(responseBuffer, {mtproto: true}); - try { + var deserializer = new TLDeserialization(responseBuffer, {mtproto: true}); var auth_key_id = deserializer.fetchLong('auth_key_id'); var msg_id = deserializer.fetchLong('msg_id'); var msg_len = deserializer.fetchInt('msg_len'); @@ -520,7 +519,13 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) mtpSendReqPQ(auth); }); - return cached[dcID] = auth.deferred.promise; + cached[dcID] = auth.deferred.promise; + + cached[dcID]['catch'](function () { + delete cached[dcID]; + }) + + return cached[dcID]; }; return {