diff --git a/app/css/mobile.css b/app/css/mobile.css index 44b63cd5..7b74b037 100644 --- a/app/css/mobile.css +++ b/app/css/mobile.css @@ -1203,9 +1203,12 @@ a.mobile_modal_action .tg_checkbox_label { .emoji-menu { margin-left: -20px; - margin-top: -267px; + margin-top: -202px; width: 262px; } +.emoji-menu .emoji-items-wrap { + height: 106px; +} .emoji-menu .emoji-items a { padding: 5px; } diff --git a/app/js/controllers.js b/app/js/controllers.js index 4e250190..54b0ce5b 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -373,7 +373,9 @@ angular.module('myApp.controllers', []) $scope.importContact = function () { AppUsersManager.openImportContact().then(function (foundContact) { if (foundContact) { - $scope.$broadcast('contact_imported'); + $rootScope.$broadcast('history_focus', { + peerString: AppUsersManager.getUserString(foundContact) + }); } }); }; @@ -496,6 +498,14 @@ angular.module('myApp.controllers', []) offset++; } $scope.dialogs.unshift(wrappedDialog); + + if (!peersInDialogs[dialog.peerID]) { + peersInDialogs[dialog.peerID] = true; + if (contactsShown) { + showMoreContacts(); + } + } + }); $scope.$on('dialog_flush', function (e, dialog) { @@ -518,12 +528,6 @@ angular.module('myApp.controllers', []) } }); - $scope.$on('contact_imported', function () { - if (contactsShown) { - loadDialogs(); - } - }) - var prevMessages = false; $scope.$watchCollection('search', function () { if ($scope.search.messages != prevMessages) { @@ -555,13 +559,15 @@ angular.module('myApp.controllers', []) } $scope.importPhonebook = function () { - PhonebookContactsService.openPhonebookImport().result.then(function (foundContacts) { - if (contactsShown && foundContacts.length) { - loadDialogs(); - } - }) + PhonebookContactsService.openPhonebookImport(); }; + $scope.$on('contacts_update', function () { + if (contactsShown) { + showMoreContacts(); + } + }); + $scope.searchClear = function () { $scope.search.query = ''; $scope.search.messages = false; @@ -630,14 +636,6 @@ angular.module('myApp.controllers', []) }); }; - $scope.importPhonebook = function () { - PhonebookContactsService.openPhonebookImport().result.then(function (foundContacts) { - if (contactsShown && foundContacts.length) { - loadDialogs(); - } - }) - }; - function loadDialogs (force) { offset = 0; maxID = 0; @@ -669,6 +667,7 @@ angular.module('myApp.controllers', []) AppMessagesManager.getDialogs('', maxID, 100); if (!dialogsResult.dialogs.length) { $scope.isEmpty.dialogs = true; + showMoreDialogs(); } } else { showMoreDialogs(); @@ -677,36 +676,40 @@ angular.module('myApp.controllers', []) }); } + function showMoreContacts () { + contactsShown = true; + + var curJump = ++jump; + AppUsersManager.getContacts($scope.search.query).then(function (contactsList) { + if (curJump != jump) return; + $scope.contacts = []; + angular.forEach(contactsList, function(userID) { + if (peersInDialogs[userID] === undefined) { + $scope.contacts.push({ + userID: userID, + user: AppUsersManager.getUser(userID), + userPhoto: AppUsersManager.getUserPhoto(userID, 'User'), + peerString: AppUsersManager.getUserString(userID) + }); + } + }); + + if (contactsList.length) { + delete $scope.isEmpty.contacts; + } else if (!$scope.search.query) { + $scope.isEmpty.contacts = true; + } + }); + $scope.$broadcast('ui_dialogs_append'); + } + function showMoreDialogs () { if (contactsShown && (!hasMore || !offset)) { return; } if (!hasMore && !$scope.search.messages && ($scope.search.query || !$scope.dialogs.length)) { - contactsShown = true; - - var curJump = ++jump; - AppUsersManager.getContacts($scope.search.query).then(function (contactsList) { - if (curJump != jump) return; - $scope.contacts = []; - angular.forEach(contactsList, function(userID) { - if (peersInDialogs[userID] === undefined) { - $scope.contacts.push({ - userID: userID, - user: AppUsersManager.getUser(userID), - userPhoto: AppUsersManager.getUserPhoto(userID, 'User'), - peerString: AppUsersManager.getUserString(userID) - }); - } - }); - - if (contactsList.length) { - delete $scope.isEmpty.contacts; - } else if (!$scope.search.query) { - $scope.isEmpty.contacts = true; - } - }); - $scope.$broadcast('ui_dialogs_append'); + showMoreContacts(); return; } @@ -2285,6 +2288,9 @@ angular.module('myApp.controllers', []) }; $scope.$watch('search.query', updateContacts); + $scope.$on('contacts_update', function () { + updateContacts($scope.search && $scope.search.query || ''); + }); $scope.toggleEdit = function (enabled) { $scope.action = enabled ? 'edit' : ''; @@ -2325,17 +2331,13 @@ angular.module('myApp.controllers', []) selectedUserIDs.push(userID); }); AppUsersManager.deleteContacts(selectedUserIDs).then(function () { - resetSelected(); - $scope.action = ''; - updateContacts($scope.search.query); + $scope.toggleEdit(false); }); } }; $scope.importContact = function () { - AppUsersManager.openImportContact().then(function () { - updateContacts($scope.search && $scope.search.query || ''); - }); + AppUsersManager.openImportContact(); }; }) diff --git a/app/js/services.js b/app/js/services.js index 9fd98818..f4d16e54 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -220,7 +220,7 @@ angular.module('myApp.services', []) onContactUpdated(foundUserID = importedContact.user_id, true); }); - return foundUserID ? 1 : 0; + return foundUserID || false; }); }; @@ -272,7 +272,7 @@ angular.module('myApp.services', []) function onContactUpdated (userID, isContact) { if (angular.isArray(contactsList)) { - var curPos = curIsContact = contactsList.indexOf(userID), + var curPos = curIsContact = contactsList.indexOf(parseInt(userID)), curIsContact = curPos != -1; if (isContact != curIsContact) { @@ -282,6 +282,7 @@ angular.module('myApp.services', []) } else { contactsList.splice(curPos, 1); } + $rootScope.$broadcast('contacts_update', userID); } } } diff --git a/app/partials/desktop/im.html b/app/partials/desktop/im.html index 943e22b6..afc6f297 100644 --- a/app/partials/desktop/im.html +++ b/app/partials/desktop/im.html @@ -15,7 +15,7 @@
diff --git a/app/partials/mobile/head.html b/app/partials/mobile/head.html index 76f0ced5..072f8646 100644 --- a/app/partials/mobile/head.html +++ b/app/partials/mobile/head.html @@ -19,7 +19,7 @@ diff --git a/app/vendor/jquery.emojiarea/jquery.emojiarea.js b/app/vendor/jquery.emojiarea/jquery.emojiarea.js index 91585625..0eb0a93e 100644 --- a/app/vendor/jquery.emojiarea/jquery.emojiarea.js +++ b/app/vendor/jquery.emojiarea/jquery.emojiarea.js @@ -484,15 +484,17 @@ '