From 31827aed3420bccbc2e199f94b4d3473399b4702 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 6 Oct 2015 13:54:14 +0300 Subject: [PATCH] Fixed can delete and can reply in channels --- app/js/controllers.js | 33 ++++++++++++++++++++++----------- app/partials/desktop/im.html | 4 ++-- app/partials/mobile/im.html | 4 ++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 935b903f..110443e7 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -453,6 +453,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) selectActions: false, botActions: false, channelActions: false, + canReply: false, + canDelete: false, actions: function () { return $scope.historyState.selectActions ? 'selected' : ($scope.historyState.botActions ? 'bot' : ($scope.historyState.channelActions ? 'channel' : false)); }, @@ -1009,6 +1011,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.historyState.selectActions = false; $scope.historyState.botActions = false; $scope.historyState.channelActions = false; + $scope.historyState.canDelete = false; + $scope.historyState.canReply = false; $scope.historyState.missedCount = 0; $scope.historyState.skipped = false; $scope.state = {}; @@ -1203,23 +1207,30 @@ angular.module('myApp.controllers', ['myApp.i18n']) var channel; if (peerID && AppPeersManager.isChannel(peerID) && - (channel = AppChatsManager.getChat(-peerID)) && - !channel.pFlags.creator && - !channel.pFlags.editor) { + (channel = AppChatsManager.getChat(-peerID))) { - if (channel.pFlags.left) { - $scope.historyState.channelActions = 'join'; - } else { - if (!$scope.historyState.channelActions) { - $scope.historyState.channelActions = 'mute'; + var canSend = channel.pFlags.creator || channel.pFlags.editor; + if (!canSend) { + if (channel.pFlags.left) { + $scope.historyState.channelActions = 'join'; + } else { + if (!$scope.historyState.channelActions) { + $scope.historyState.channelActions = 'mute'; + } + NotificationsManager.getPeerMuted(peerID).then(function (muted) { + $scope.historyState.channelActions = muted ? 'unmute' : 'mute'; + }); } - NotificationsManager.getPeerMuted(peerID).then(function (muted) { - $scope.historyState.channelActions = muted ? 'unmute' : 'mute'; - }); + } else { + $scope.historyState.channelActions = false; } + $scope.historyState.canReply = canSend; + $scope.historyState.canDelete = canSend || channel.pFlags.moderator; } else { $scope.historyState.channelActions = false; + $scope.historyState.canReply = true; + $scope.historyState.canDelete = true; } if (wasChannelActions != $scope.historyState.channelActions) { $scope.$broadcast('ui_panel_update'); diff --git a/app/partials/desktop/im.html b/app/partials/desktop/im.html index 1e49d933..7d1ed32f 100644 --- a/app/partials/desktop/im.html +++ b/app/partials/desktop/im.html @@ -158,8 +158,8 @@
- - + +
diff --git a/app/partials/mobile/im.html b/app/partials/mobile/im.html index 6a0bec1a..98fe7a48 100644 --- a/app/partials/mobile/im.html +++ b/app/partials/mobile/im.html @@ -127,8 +127,8 @@
- - + +