diff --git a/app/js/controllers.js b/app/js/controllers.js index a5bccfb2..fa39754b 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -2179,7 +2179,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) return; } - var needMentions = peerBots.length > 1; + var needMentions = peerID < 0; var commandsList = []; var commandsIndex = SearchIndexManager.createIndex(); @@ -3304,6 +3304,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) }); } + $scope.hasRights = function (action) { + return AppChatsManager.hasRights($scope.chatID, action); + } + }) .controller('ChannelModalController', function ($scope, $timeout, $rootScope, $modal, AppUsersManager, AppChatsManager, AppProfileManager, AppPhotosManager, MtpApiManager, MtpApiFileManager, NotificationsManager, AppMessagesManager, AppPeersManager, ApiUpdatesManager, ContactsSelectService, ErrorService) { @@ -3452,6 +3456,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) $rootScope.$broadcast('history_focus', {peerString: $scope.chatFull.peerString}); }; + $scope.hasRights = function (action) { + return AppChatsManager.hasRights($scope.chatID, action); + } + }) .controller('SettingsModalController', function ($rootScope, $scope, $timeout, $modal, AppUsersManager, AppChatsManager, AppPhotosManager, MtpApiManager, Storage, NotificationsManager, MtpApiFileManager, PasswordManager, ApiUpdatesManager, ChangelogNotifyService, LayoutSwitchService, AppRuntimeManager, ErrorService, _) { diff --git a/app/js/directives.js b/app/js/directives.js index 86f9b6f6..03fd6f61 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -2621,18 +2621,20 @@ angular.module('myApp.directives', ['myApp.filters']) var update = function () { var html = allPluralize(participantsCount); var onlineCount = 0; - var wasMe = false; - angular.forEach(participants, function (t, userID) { - var user = AppUsersManager.getUser(userID); - if (user.status && user.status._ == 'userStatusOnline') { - if (user.id == myID) { - wasMe = true; + if (!AppChatsManager.isChannel(chatID)) { + var wasMe = false; + angular.forEach(participants, function (t, userID) { + var user = AppUsersManager.getUser(userID); + if (user.status && user.status._ == 'userStatusOnline') { + if (user.id == myID) { + wasMe = true; + } + onlineCount++; } - onlineCount++; + }); + if (onlineCount > 1 || onlineCount == 1 && !wasMe) { + html = _('group_modal_participants', {total: html, online: onlinePluralize(onlineCount)}); } - }); - if (onlineCount > 1 || onlineCount == 1 && !wasMe) { - html = _('group_modal_participants', {total: html, online: onlinePluralize(onlineCount)}); } if (!onlineCount && !participantsCount) { html = ''; diff --git a/app/js/services.js b/app/js/services.js index 4bbae001..8b3a0757 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -613,12 +613,37 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) chat.pFlags.left) { return false; } - if (isChannel(id) && action == 'send') { - if (!chat.pFlags.megagroup && - !chat.pFlags.creator && - !chat.pFlags.editor) { - return false; - } + if (chat.pFlags.creator) { + return true; + } + + switch (action) { + case 'send': + if (chat._ == 'channel' && + !chat.pFlags.megagroup && + !chat.pFlags.editor) { + return false; + } + break; + + case 'edit_title': + case 'edit_photo': + case 'invite': + if (chat._ == 'channel') { + if (chat.pFlags.megagroup) { + if (!chat.pFlags.editor) { + return false; + } + } else { + return false; + } + } else { + if (chat.pFlags.admins_enabled && + !chat.pFlags.editor) { + return false; + } + } + break; } return true; } @@ -1003,7 +1028,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) function getPeerBots (peerID) { var peerBots = []; if (peerID >= 0 && !AppUsersManager.isBot(peerID) || - AppPeersManager.isChannel(peerID)) { + (AppPeersManager.isChannel(peerID) && !AppPeersManager.isMegagroup(peerID))) { return $q.when(peerBots); } if (peerID >= 0) { @@ -1080,7 +1105,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) channel: AppChatsManager.getChannelInput(id), filter: {_: 'channelParticipantsRecent'}, offset: 0, - limit: 200 + limit: AppChatsManager.isMegagroup(id) ? 50 : 200 }).then(function (result) { AppUsersManager.saveApiUsers(result.users); return result.participants; @@ -1107,10 +1132,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } NotificationsManager.savePeerSettings(-id, fullChannel.notify_settings); var participantsPromise; - if ((fullChannel.flags & 8) || - chat.pFlags.creator || - chat.pFlags.editor || - chat.pFlags.moderator) { + if (fullChannel.flags & 8) { participantsPromise = getChannelParticipants(id).then(function (participants) { delete chatFullPromises[id]; fullChannel.participants = { @@ -2729,6 +2751,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) channelID = update.channel_id; break; } + if (channelID && !AppChatsManager.hasChat(channelID)) { + return false; + } var curState = channelID ? getChannelState(channelID, update.pts) : updatesState; // console.log('process', channelID, curState, update); diff --git a/app/partials/desktop/channel_modal.html b/app/partials/desktop/channel_modal.html index 885d6c92..1654c78c 100644 --- a/app/partials/desktop/channel_modal.html +++ b/app/partials/desktop/channel_modal.html @@ -4,7 +4,7 @@
- +
@@ -28,7 +28,7 @@
-
+
@@ -71,7 +71,7 @@
-