From 19b23402f23de9d86ee2ee23a078288f66e794f3 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 20 Nov 2014 23:20:39 +0300 Subject: [PATCH] Added simple user blocking --- app/js/controllers.js | 10 ++++++++++ app/js/locales/en-us.json | 2 ++ app/partials/desktop/user_modal.html | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/app/js/controllers.js b/app/js/controllers.js index dc9c11c1..9f1e42b2 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1846,6 +1846,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.user = AppUsersManager.getUser($scope.userID); $scope.userPhoto = AppUsersManager.getUserPhoto($scope.userID, 'User'); + $scope.blocked = false; $scope.settings = {notifications: true}; @@ -1862,6 +1863,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) if (userFullResult.profile_photo._ != 'photoEmpty') { $scope.userPhoto.id = userFullResult.profile_photo.id; } + $scope.blocked = userFullResult.blocked; NotificationsManager.savePeerSettings($scope.userID, userFullResult.notify_settings); 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 () { PeersSelectService.selectPeer({confirm_type: 'SHARE_CONTACT_PEER'}).then(function (peerString) { var peerID = AppPeersManager.getPeerID(peerString); diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 2df7ff13..cd0f016f 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -69,6 +69,8 @@ "user_modal_delete_contact": "Delete contact", "user_modal_add_contact": "Add to contacts", "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_info": "Info", "user_modal_phone": "Phone", diff --git a/app/partials/desktop/user_modal.html b/app/partials/desktop/user_modal.html index 01234c2f..563b9599 100644 --- a/app/partials/desktop/user_modal.html +++ b/app/partials/desktop/user_modal.html @@ -36,6 +36,12 @@
  • +
  • + + + + +