From 81448595bb2ec17fc7d217bd16aa7782671047a4 Mon Sep 17 00:00:00 2001 From: Aziz Khakulov Date: Fri, 12 Jan 2018 13:49:59 +0100 Subject: [PATCH] Multi-forward functionality #1492 (#1588) * Multi forward functionality #1492 * Remove unused variable * Changes according to pull request review 88460714 --- app/js/controllers.js | 59 +++++++++++++++++++++++++++----- app/less/desktop.less | 20 +++++++++++ app/partials/desktop/dialog.html | 2 ++ 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 2dcd3a9d..8e35b1bf 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1941,15 +1941,34 @@ angular.module('myApp.controllers', ['myApp.i18n']) }) } if (selectedMessageIDs.length) { - PeersSelectService.selectPeer({canSend: true}).then(function (peerString) { + PeersSelectService.selectPeer({canSend: true}).then(function (peerStrings) { selectedCancel() - $rootScope.$broadcast('history_focus', { - peerString: peerString, - attachment: { - _: 'fwd_messages', - id: selectedMessageIDs - } - }) + if (Array.isArray(peerStrings) && peerStrings.length > 1) { + angular.forEach(peerStrings, function (peerString) { + var peerID = AppPeersManager.getPeerID(peerString) + AppMessagesManager.forwardMessages(peerID, selectedMessageIDs) + }) + var toastData = toaster.pop({ + type: 'info', + body: _('confirm_modal_forward_to_peer_success'), + bodyOutputType: 'trustedHtml', + clickHandler: function () { + $rootScope.$broadcast('history_focus', { + peerString: peerStrings[0] + }) + toaster.clear(toastData) + }, + showCloseButton: false + }) + } else { + $rootScope.$broadcast('history_focus', { + peerString: peerStrings, + attachment: { + _: 'fwd_messages', + id: selectedMessageIDs + } + }) + } }) } } @@ -4926,6 +4945,30 @@ angular.module('myApp.controllers', ['myApp.i18n']) }) } + $scope.dialogMultiSelect = function(peerString, event) { + var peerID = AppPeersManager.getPeerID(peerString) + $scope.multiSelect = $scope.selectedPeers[peerID] == undefined || + $scope.selectedPeers[peerID] != undefined && Object.keys($scope.selectedPeers).length > 1 + if ($scope.selectedPeers[peerID]) { + delete $scope.selectedPeers[peerID] + $scope.selectedCount-- + var pos = $scope.selectedPeerIDs.indexOf(peerID) + if (pos >= 0) { + $scope.selectedPeerIDs.splice(pos, 1) + } + } else { + $scope.selectedPeers[peerID] = AppPeersManager.getPeer(peerID) + $scope.selectedCount++ + $scope.selectedPeerIDs.unshift(peerID) + } + cancelEvent(event) + } + + $scope.isSelected = function(peerString){ + var peerID = AppPeersManager.getPeerID(peerString) + return $scope.selectedPeers[peerID] != undefined + } + $scope.dialogSelect = function (peerString) { var peerID if (!$scope.multiSelect) { diff --git a/app/less/desktop.less b/app/less/desktop.less index dad1ebb3..6bcc83e6 100644 --- a/app/less/desktop.less +++ b/app/less/desktop.less @@ -964,6 +964,26 @@ a.footer_link.active:active { .icon-select-tick { display: none; + + .im_dialogs_modal_list .im_dialog_wrap .im_dialog &{ + display: block; + margin: 10px 5px 0 -5px; + position: relative; + float: left; + width: 26px; + height: 26px; + .image-2x('../img/icons/IconsetW.png', 42px, 1171px); + background-position: -9px -481px; + opacity: 0.5; + } + + .im_dialogs_modal_list .im_dialog_wrap:hover .im_dialog &{ + opacity: 0.75; + } + + &.dialog_selected{ + opacity: 1 !important; + } } @media (min-width: 900px) { diff --git a/app/partials/desktop/dialog.html b/app/partials/desktop/dialog.html index d4aa2a96..7fe724c9 100644 --- a/app/partials/desktop/dialog.html +++ b/app/partials/desktop/dialog.html @@ -18,6 +18,8 @@ > + +