Skip to content

Commit

Permalink
Remove selected torrents with delete key
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisl9029 authored and tympanix committed Sep 16, 2021
1 parent 6c238d7 commit 6d1ecfe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/scripts/components/menuWin.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ angular.module('torrentApp').factory("menuWin", ['electron', '$rootScope', '$bit
accelerator: 'CmdOrCtrl+V',
role: 'paste'
},
{
label: 'Remove',
accelerator: 'Delete',
click() {
if (document.activeElement.nodeName !== 'INPUT') {
$rootScope.$broadcast('menu:remove')
}
},
},
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
Expand Down
6 changes: 6 additions & 0 deletions src/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ angular.module("torrentApp").controller("mainController", ["$rootScope", "$scope
}
})

$scope.$on('menu:remove', function(event) {
if (page === PAGE_TORRENTS) {
$scope.$broadcast('remove:torrents')
}
})

$scope.connectToServer = function(server) {
connectToServer(server)
}
Expand Down
10 changes: 10 additions & 0 deletions src/scripts/controllers/torrents.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ angular.module("torrentApp").controller("torrentsController", ["$rootScope", "$s
selectAll()
})

$scope.$on('remove:torrents', function(){
remove()
})

function remove() {
var selectedTorrents = $scope.arrayTorrents.filter(torrent => torrent.selected)
$rootScope.$btclient.remove(selectedTorrents)
$scope.$apply()
}

function selectAll() {
deselectAll()
for (var i = 0; i < $scope.arrayTorrents.length; i++){
Expand Down

0 comments on commit 6d1ecfe

Please sign in to comment.