Browse Source

Fixed can delete and can reply in channels

master
Igor Zhukov 9 years ago
parent
commit
31827aed34
  1. 33
      app/js/controllers.js
  2. 4
      app/partials/desktop/im.html
  3. 4
      app/partials/mobile/im.html

33
app/js/controllers.js

@ -453,6 +453,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
selectActions: false, selectActions: false,
botActions: false, botActions: false,
channelActions: false, channelActions: false,
canReply: false,
canDelete: false,
actions: function () { actions: function () {
return $scope.historyState.selectActions ? 'selected' : ($scope.historyState.botActions ? 'bot' : ($scope.historyState.channelActions ? 'channel' : false)); 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.selectActions = false;
$scope.historyState.botActions = false; $scope.historyState.botActions = false;
$scope.historyState.channelActions = false; $scope.historyState.channelActions = false;
$scope.historyState.canDelete = false;
$scope.historyState.canReply = false;
$scope.historyState.missedCount = 0; $scope.historyState.missedCount = 0;
$scope.historyState.skipped = false; $scope.historyState.skipped = false;
$scope.state = {}; $scope.state = {};
@ -1203,23 +1207,30 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var channel; var channel;
if (peerID && if (peerID &&
AppPeersManager.isChannel(peerID) && AppPeersManager.isChannel(peerID) &&
(channel = AppChatsManager.getChat(-peerID)) && (channel = AppChatsManager.getChat(-peerID))) {
!channel.pFlags.creator &&
!channel.pFlags.editor) {
if (channel.pFlags.left) { var canSend = channel.pFlags.creator || channel.pFlags.editor;
$scope.historyState.channelActions = 'join'; if (!canSend) {
} else { if (channel.pFlags.left) {
if (!$scope.historyState.channelActions) { $scope.historyState.channelActions = 'join';
$scope.historyState.channelActions = 'mute'; } 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) { } else {
$scope.historyState.channelActions = muted ? 'unmute' : 'mute'; $scope.historyState.channelActions = false;
});
} }
$scope.historyState.canReply = canSend;
$scope.historyState.canDelete = canSend || channel.pFlags.moderator;
} }
else { else {
$scope.historyState.channelActions = false; $scope.historyState.channelActions = false;
$scope.historyState.canReply = true;
$scope.historyState.canDelete = true;
} }
if (wasChannelActions != $scope.historyState.channelActions) { if (wasChannelActions != $scope.historyState.channelActions) {
$scope.$broadcast('ui_panel_update'); $scope.$broadcast('ui_panel_update');

4
app/partials/desktop/im.html

@ -158,8 +158,8 @@
<div ng-switch-when="selected" class="im_edit_selected_actions" my-i18n> <div ng-switch-when="selected" class="im_edit_selected_actions" my-i18n>
<a class="btn btn-md btn-md-primary im_edit_cancel_link" ng-click="selectedCancel()" my-i18n="modal_cancel"></a> <a class="btn btn-md btn-md-primary im_edit_cancel_link" ng-click="selectedCancel()" my-i18n="modal_cancel"></a>
<a class="btn btn-primary im_edit_forward_btn" ng-click="selectedForward()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_forward"></a> <a class="btn btn-primary im_edit_forward_btn" ng-click="selectedForward()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_forward"></a>
<a class="btn btn-primary im_edit_delete_btn" ng-click="selectedDelete()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_delete"></a> <a class="btn btn-primary im_edit_delete_btn" ng-click="selectedDelete()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_delete" ng-show="historyState.canDelete"></a>
<a class="btn btn-primary im_edit_reply_btn" ng-click="selectedReply()" ng-show="selectedCount == 1" my-i18n="im_reply"></a> <a class="btn btn-primary im_edit_reply_btn" ng-click="selectedReply()" ng-show="selectedCount == 1 &amp;&amp; historyState.canReply" my-i18n="im_reply"></a>
<my-i18n-param name="count"><strong class="im_selected_count" ng-show="selectedCount > 0" ng-bind="selectedCount"></strong></my-i18n-param> <my-i18n-param name="count"><strong class="im_selected_count" ng-show="selectedCount > 0" ng-bind="selectedCount"></strong></my-i18n-param>
</div> </div>
</div> </div>

4
app/partials/mobile/im.html

@ -127,8 +127,8 @@
<div ng-switch-when="selected" class="im_edit_selected_actions" my-i18n> <div ng-switch-when="selected" class="im_edit_selected_actions" my-i18n>
<a class="btn btn-md btn-md-primary im_edit_cancel_link" ng-click="selectedCancel()" my-i18n="modal_cancel"></a> <a class="btn btn-md btn-md-primary im_edit_cancel_link" ng-click="selectedCancel()" my-i18n="modal_cancel"></a>
<a class="btn btn-primary im_edit_forward_btn" ng-click="selectedForward()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_forward"></a> <a class="btn btn-primary im_edit_forward_btn" ng-click="selectedForward()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_forward"></a>
<a class="btn btn-primary im_edit_delete_btn" ng-click="selectedDelete()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_delete"></a> <a class="btn btn-primary im_edit_delete_btn" ng-click="selectedDelete()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_delete" ng-show="historyState.canDelete"></a>
<a class="btn btn-primary im_edit_reply_btn" ng-click="selectedReply()" ng-show="selectedCount == 1" my-i18n="im_reply"></a> <a class="btn btn-primary im_edit_reply_btn" ng-click="selectedReply()" ng-show="selectedCount == 1 &amp;&amp; historyState.canReply" my-i18n="im_reply"></a>
<my-i18n-param name="count"><strong class="im_selected_count" ng-show="selectedCount > 0" ng-bind="selectedCount"></strong></my-i18n-param> <my-i18n-param name="count"><strong class="im_selected_count" ng-show="selectedCount > 0" ng-bind="selectedCount"></strong></my-i18n-param>
</div> </div>
</div> </div>

Loading…
Cancel
Save