From d946e85a478754296f5ad19c72e01ee629015b43 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sat, 1 Mar 2014 18:27:39 +0100 Subject: [PATCH] Bugfixes --- app/js/controllers.js | 11 ++++------- app/js/lib/mtproto.js | 3 +++ app/js/services.js | 6 ++++-- app/partials/chat_modal.html | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 397061b7..c7ca2d4d 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -871,10 +871,10 @@ angular.module('myApp.controllers', []) }); ContactsSelectService.selectContacts({disabled: disabled}).then(function (userIDs) { - angular.forEach(userIDs, function () { + angular.forEach(userIDs, function (userID) { MtpApiManager.invokeApi('messages.addChatUser', { chat_id: $scope.chatID, - user_id: {_: 'inputUserContact', user_id: userIDs}, + user_id: {_: 'inputUserContact', user_id: userID}, fwd_limit: 100 }).then(function (addResult) { AppUsersManager.saveApiUsers(addResult.users); @@ -1049,7 +1049,6 @@ angular.module('myApp.controllers', []) $scope.disabledContacts[$scope.disabled[i]] = true; } } - console.log($scope.disabled, $scope.disabledContacts); if ($scope.selected) { for (var i = 0; i < $scope.selected.length; i++) { @@ -1111,7 +1110,7 @@ angular.module('myApp.controllers', []) }) - .controller('ChatCreateModalController', function ($scope, $modalInstance, $rootScope, MtpApiManager, AppChatsManager) { + .controller('ChatCreateModalController', function ($scope, $modalInstance, $rootScope, MtpApiManager, AppUsersManager, AppChatsManager, ApiUpdatesManager) { $scope.group = {name: ''}; $scope.createGroup = function () { @@ -1126,8 +1125,6 @@ angular.module('myApp.controllers', []) title: $scope.group.name, users: inputUsers }).then(function (createdResult) { - $modalInstance.close(); - AppUsersManager.saveApiUsers(createdResult.users); AppChatsManager.saveApiChats(createdResult.chats); @@ -1139,7 +1136,7 @@ angular.module('myApp.controllers', []) }); } - var peerString = AppChatsManager.getChatString(message.to_id.chat_id); + var peerString = AppChatsManager.getChatString(createdResult.message.to_id.chat_id); $rootScope.$broadcast('history_focus', {peerString: peerString}); }); }; diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index 55ab9707..c15c29ac 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -1507,6 +1507,8 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato offline; $rootScope.offline = true; + $rootScope.offlineConnecting = true; + $rootScope.retryOnline = function () { $(document.body).trigger('online'); } @@ -1802,6 +1804,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato this.offline = enabled; $rootScope.offline = enabled; + $rootScope.offlineConnecting = false; if (this.offline) { $timeout.cancel(this.nextReqPromise); diff --git a/app/js/services.js b/app/js/services.js index 77fc1470..c0c6fc8a 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -372,7 +372,7 @@ angular.module('myApp.services', []) participant.user = AppUsersManager.getUser(participant.user_id); participant.userPhoto = AppUsersManager.getUserPhoto(participant.user_id, 'User'); participant.inviter = AppUsersManager.getUser(participant.inviter_id); - participant.canKick = myID == chat.admin_id || myID == participant.inviter_id; + participant.canKick = myID != participant.user_id && (myID == chat.admin_id || myID == participant.inviter_id); }); }); } @@ -2376,13 +2376,15 @@ angular.module('myApp.services', []) if (!started) { started = true; $rootScope.$watch('idle.isIDLE', checkIDLE); + $rootScope.$watch('offline', checkIDLE); } } function sendUpdateStatusReq(offline) { var date = tsNow(); if (offline && !lastOnlineUpdated || - !offline && (date - lastOnlineUpdated) < 50000) { + !offline && (date - lastOnlineUpdated) < 50000 || + $rootScope.offline) { return; } lastOnlineUpdated = offline ? 0 : date; diff --git a/app/partials/chat_modal.html b/app/partials/chat_modal.html index 843c9833..1b24baac 100644 --- a/app/partials/chat_modal.html +++ b/app/partials/chat_modal.html @@ -53,7 +53,7 @@
- Kick + Kick