Browse Source

Added simple user blocking

master
Igor Zhukov 10 years ago
parent
commit
19b23402f2
  1. 10
      app/js/controllers.js
  2. 2
      app/js/locales/en-us.json
  3. 6
      app/partials/desktop/user_modal.html

10
app/js/controllers.js

@ -1846,6 +1846,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.user = AppUsersManager.getUser($scope.userID); $scope.user = AppUsersManager.getUser($scope.userID);
$scope.userPhoto = AppUsersManager.getUserPhoto($scope.userID, 'User'); $scope.userPhoto = AppUsersManager.getUserPhoto($scope.userID, 'User');
$scope.blocked = false;
$scope.settings = {notifications: true}; $scope.settings = {notifications: true};
@ -1862,6 +1863,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (userFullResult.profile_photo._ != 'photoEmpty') { if (userFullResult.profile_photo._ != 'photoEmpty') {
$scope.userPhoto.id = userFullResult.profile_photo.id; $scope.userPhoto.id = userFullResult.profile_photo.id;
} }
$scope.blocked = userFullResult.blocked;
NotificationsManager.savePeerSettings($scope.userID, userFullResult.notify_settings); NotificationsManager.savePeerSettings($scope.userID, userFullResult.notify_settings);
NotificationsManager.getPeerMuted($scope.userID).then(function (muted) { NotificationsManager.getPeerMuted($scope.userID).then(function (muted) {
@ -1922,6 +1924,14 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}); });
}; };
$scope.toggleBlock = function (block) {
MtpApiManager.invokeApi(block ? 'contacts.block' : 'contacts.unblock', {
id: AppUsersManager.getUserInput($scope.userID)
}).then(function () {
$scope.blocked = block;
});
};
$scope.shareContact = function () { $scope.shareContact = function () {
PeersSelectService.selectPeer({confirm_type: 'SHARE_CONTACT_PEER'}).then(function (peerString) { PeersSelectService.selectPeer({confirm_type: 'SHARE_CONTACT_PEER'}).then(function (peerString) {
var peerID = AppPeersManager.getPeerID(peerString); var peerID = AppPeersManager.getPeerID(peerString);

2
app/js/locales/en-us.json

@ -69,6 +69,8 @@
"user_modal_delete_contact": "Delete contact", "user_modal_delete_contact": "Delete contact",
"user_modal_add_contact": "Add to contacts", "user_modal_add_contact": "Add to contacts",
"user_modal_share_contact": "Share contact", "user_modal_share_contact": "Share contact",
"user_modal_block_user": "Block user",
"user_modal_unblock_user": "Unblock user",
"user_modal_delete_chat": "Delete chat", "user_modal_delete_chat": "Delete chat",
"user_modal_info": "Info", "user_modal_info": "Info",
"user_modal_phone": "Phone", "user_modal_phone": "Phone",

6
app/partials/desktop/user_modal.html

@ -36,6 +36,12 @@
<li ng-if="user.phone.length > 0 &amp;&amp; user._ != 'userContact'"> <li ng-if="user.phone.length > 0 &amp;&amp; user._ != 'userContact'">
<a ng-click="importContact()" my-i18n="user_modal_add_contact"></a> <a ng-click="importContact()" my-i18n="user_modal_add_contact"></a>
</li> </li>
<li ng-if="user._ != 'userSelf'">
<a ng-click="toggleBlock(!blocked)" ng-switch="blocked">
<my-i18n ng-switch-when="true" msgid="user_modal_unblock_user"></my-i18n>
<my-i18n ng-switch-default msgid="user_modal_block_user"></my-i18n>
</a>
</li>
<li ng-if="user.phone.length > 0"> <li ng-if="user.phone.length > 0">
<a ng-click="shareContact()" my-i18n="user_modal_share_contact"></a> <a ng-click="shareContact()" my-i18n="user_modal_share_contact"></a>
</li> </li>

Loading…
Cancel
Save