Add copy comment functionality to the torrent list's context menu

PR #19846.
Closes #18890.
This commit is contained in:
thalieht 2023-11-07 11:42:31 +02:00 committed by GitHub
parent f067ab1692
commit 30d9978c97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 0 deletions

View file

@ -89,6 +89,7 @@ let copyNameFN = function() {};
let copyInfohashFN = function(policy) {};
let copyMagnetLinkFN = function() {};
let copyIdFN = function() {};
let copyCommentFN = function() {};
let setQueuePositionFN = function() {};
let exportTorrentFN = function() {};
@ -1005,6 +1006,21 @@ const initializeWindows = function() {
return torrentsTable.selectedRowsIds().join("\n");
};
copyCommentFN = function() {
const selectedRows = torrentsTable.selectedRowsIds();
const comments = [];
if (selectedRows.length > 0) {
const rows = torrentsTable.getFilteredAndSortedRows();
for (let i = 0; i < selectedRows.length; ++i) {
const hash = selectedRows[i];
const comment = rows[hash].full_data.comment;
if (comment && (comment !== ""))
comments.push(comment);
}
}
return comments.join("\n---------\n");
};
exportTorrentFN = async function() {
const hashes = torrentsTable.selectedRowsIds();
for (const hash of hashes) {