diff --git a/app/js/controllers.js b/app/js/controllers.js index 689593f5..9b964a87 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -620,7 +620,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.dialogs = []; $scope.contacts = []; - $scope.foundUsers = []; + $scope.foundPeers = []; $scope.foundMessages = []; if ($scope.search === undefined) { @@ -854,7 +854,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) if (!searchMessages) { $scope.dialogs = []; $scope.contacts = []; - $scope.foundUsers = []; + $scope.foundPeers = []; } $scope.foundMessages = []; @@ -966,15 +966,16 @@ angular.module('myApp.controllers', ['myApp.i18n']) if (curJump != contactsJump) return; MtpApiManager.invokeApi('contacts.search', {q: $scope.search.query, limit: 10}).then(function (result) { AppUsersManager.saveApiUsers(result.users); + AppChatsManager.saveApiChats(result.chats); if (curJump != contactsJump) return; - $scope.foundUsers = []; + $scope.foundPeers = []; angular.forEach(result.results, function(contactFound) { - var userID = contactFound.user_id; - if (peersInDialogs[userID] === undefined) { - $scope.foundUsers.push({ - userID: userID, - user: AppUsersManager.getUser(userID), - peerString: AppUsersManager.getUserString(userID) + var peerID = AppPeersManager.getPeerID(contactFound); + if (peersInDialogs[peerID] === undefined) { + $scope.foundPeers.push({ + id: peerID, + username: AppPeersManager.getPeer(peerID).username, + peerString: AppUsersManager.getUserString(peerID) }); } }); @@ -1726,6 +1727,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) if (updPeerID == $scope.curDialog.peerID) { $location.url('/im'); } + historiesQueuePop(updPeerID); }); $scope.$on('notify_settings', function (e, data) { @@ -3926,7 +3928,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) .controller('ContactsModalController', function ($scope, $timeout, $modal, $modalInstance, MtpApiManager, AppUsersManager, ErrorService) { $scope.contacts = []; - $scope.foundUsers = []; + $scope.foundPeers = []; $scope.search = {}; $scope.slice = {limit: 20, limitDelta: 20}; diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 45a2c7de..23418799 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -217,6 +217,7 @@ "confirm_modal_abort_password_setup": "Abort two-step verification setup?", "confirm_modal_reset_account_md": "Are you sure?\nThis action can not be undone.\n\nYou will lose all your chats and messages, along with any media and files you shared, if you proceed with resetting your account.", "confirm_modal_join_group_link": "Do you want to join the group «{title}»?", + "confirm_modal_join_channel_link": "Do you want to join the channel «{title}»?", "confirm_modal_revoke_group_link": "Are you sure you want to revoke this link? Once you do, no one will be able to join the group using it.", "confirm_modal_revoke_channel_link": "Are you sure you want to revoke this link? Once you do, no one will be able to join the channel using it.", "confirm_modal_delete_channel_md": "Are you sure you want to delete this channel?\n\nAll messages will be removed and all messages will be lost.", @@ -363,6 +364,8 @@ "error_modal_password_disabled_descripion": "You have disabled Two-Step Verification.", "error_modal_user_not_mutual_contact": "The user can be invited by his contact only", "error_modal_invite_link_invalid": "The invite link is invalid", + "error_modal_channel_not_accessible": "Sorry, this channel is not accessible.", + "error_modal_not_contact_flood": "Sorry, you can only send messages to mutual contacts at the moment. {more-info-link: More info »}", "head_telegram": "Telegram", diff --git a/app/js/messages_manager.js b/app/js/messages_manager.js index ff47da1c..01ef488d 100644 --- a/app/js/messages_manager.js +++ b/app/js/messages_manager.js @@ -314,7 +314,7 @@ angular.module('myApp.services') offset_id: maxID ? getMessageLocalID(maxID) : 0, add_offset: offset || 0, limit: limit || 0 - }, {noErrorBox: true}); + }); } else { promise = MtpApiManager.invokeApi('messages.getHistory', { peer: inputPeer, @@ -365,6 +365,23 @@ angular.module('myApp.services') } return historyResult; }); + }, function (error) { + switch (error.type) { + case 'CHANNEL_PRIVATE': + var channel = AppChatsManager.getChat(-peerID); + channel = {_: 'channelForbidden', access_hash: channel.access_hash, title: channel.title}; + ApiUpdatesManager.processUpdateMessage({ + _: 'updates', + updates: [{ + _: 'updateChannel', + channel_id: -peerID + }], + chats: [channel], + users: [] + }); + break; + } + return $q.reject(error); }); } @@ -1599,7 +1616,7 @@ angular.module('myApp.services') chatTitle = chatInvite.title; } ErrorService.confirm({ - type: 'JOIN_GROUP_BY_LINK', + type: chatInvite.flags & 1 ? 'JOIN_CHANNEL_BY_LINK' : 'JOIN_GROUP_BY_LINK', title: chatTitle }).then(function () { return MtpApiManager.invokeApi('messages.importChatInvite', { diff --git a/app/js/services.js b/app/js/services.js index 859b4460..6fd7d2c0 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -418,9 +418,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) case 'updateUserPhoto': var userID = update.user_id; - if (users[userID]) { + var user = users[userID]; + if (user) { forceUserOnline(userID); - safeReplaceObject(users[userID].photo, update.photo); + if (!user.photo) { + user.photo = update.photo; + } else { + safeReplaceObject(user.photo, update.photo); + } if (cachedPhotoLocations[userID] !== undefined) { safeReplaceObject(cachedPhotoLocations[userID], update.photo && update.photo.photo_small || {empty: true}); @@ -619,7 +624,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) function isChannel (id) { var chat = chats[id]; - if (chat && chat._ == 'channel' || + if (chat && (chat._ == 'channel' || chat._ == 'channelForbidden') || channelAccess[id]) { return true; } @@ -965,7 +970,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } }) -.service('AppProfileManager', function ($q, $rootScope, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, NotificationsManager, MtpApiManager, RichTextProcessor) { +.service('AppProfileManager', function ($q, $rootScope, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, NotificationsManager, MtpApiManager, ApiUpdatesManager, RichTextProcessor) { var botInfos = {}; var chatsFull = {}; @@ -1129,6 +1134,22 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return fullChannel; }); + }, function (error) { + switch (error.type) { + case 'CHANNEL_PRIVATE': + var channel = AppChatsManager.getChat(id); + channel = {_: 'channelForbidden', access_hash: channel.access_hash, title: channel.title}; + ApiUpdatesManager.processUpdateMessage({ + _: 'updates', + updates: [{ + _: 'updateChannel', + channel_id: id + }], + chats: [channel], + users: [] + }); + break; + } }); } diff --git a/app/partials/desktop/confirm_modal.html b/app/partials/desktop/confirm_modal.html index a94e02fa..3af146ab 100644 --- a/app/partials/desktop/confirm_modal.html +++ b/app/partials/desktop/confirm_modal.html @@ -48,6 +48,9 @@