Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extsearch: Fix regressions by #2588 #2620

Merged
merged 3 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1912,7 +1912,7 @@ var theWebUI =
return(e.fromTextCtrl);
},

contextMenuTable: function(labelType, el) {
contextMenuTable: function(panelId, labelId) {
return theWebUI.getTable('trt');
},

Expand Down
24 changes: 14 additions & 10 deletions plugins/datadir/init.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
plugin.loadMainCSS();
plugin.loadLang();

function firstSelectedTorrent() {
const table = theWebUI.getTable("trt");
const id = table.selCount > 0 ? table.getFirstSelected() : null;
return id && id.length === 40 ? theWebUI.torrents[id] : undefined;
}

theWebUI.EditDataDir = function()
{
var id = theWebUI.getTable("trt").getFirstSelected();
if( id && (id.length==40) && this.torrents[id] )
const torrent = firstSelectedTorrent();
if( torrent )
{
var save_path = this.torrents[id].save_path.trim();
var save_path = torrent.save_path.trim();
if( !save_path.length ) // torrent is not open
this.request( "?action=getsavepath&hash=" + id, [this.showDataDirDlg, this] );
else
Expand All @@ -16,13 +22,13 @@ theWebUI.EditDataDir = function()

theWebUI.showDataDirDlg = function( d )
{
var id = theWebUI.getTable("trt").getFirstSelected();
var is_done = false;
var is_multy = false;
if( id && (id.length==40) && this.torrents[id] )
const torrent = firstSelectedTorrent();
if( torrent )
{
is_done = String(this.torrents[id].done).trim() === "1000";
is_multy = String(this.torrents[id].multi_file).trim() !== "0";
is_done = String(torrent.done).trim() === "1000";
is_multy = String(torrent.multi_file).trim() !== "0";
}
$('#edit_datadir').val( d.savepath.trim() );
$('#btn_datadir_ok').prop("disabled",false);
Expand Down Expand Up @@ -73,12 +79,10 @@ if(plugin.canChangeMenu())
plugin.createMenu.call(this, e, id);
if(plugin.enabled && plugin.allStuffLoaded)
{
var table = this.getTable("trt");

var el = theContextMenu.get( theUILang.Properties );
if( el )
theContextMenu.add( el, [theUILang.DataDir + "...",
((table.selCount > 1) || (table.getFirstSelected().length==40)) ? "theWebUI.EditDataDir()" : null] );
firstSelectedTorrent() ? "theWebUI.EditDataDir()" : null] );
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions plugins/extsearch/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ catlist.switchLabel = function(panelId, targetId, toggle=false, range=false)
}
table.scrollTo(0);
table.calcSize().resizeHack();
} else {
} else if (tegList.is(":visible")) {
// switch away from extsearch view
tegList.hide();
list.show();
Expand Down Expand Up @@ -429,10 +429,10 @@ function idIsExTeg(labelId) {
}

plugin.contextMenuTable = theWebUI.contextMenuTable;
theWebUI.contextMenuTable = function(panelId, el) {
return panelId === 'psearch' && idIsExTeg(el.id) ?
theWebUI.contextMenuTable = function(panelId, labelId) {
return panelId === 'psearch' && idIsExTeg(labelId) ?
theWebUI.getTable('teg')
: plugin.contextMenuTable.call(theWebUI, panelId, el);
: plugin.contextMenuTable.call(theWebUI, panelId, labelId);
},

plugin.contextMenuEntries = catlist.contextMenuEntries.bind(catlist);
Expand All @@ -444,7 +444,7 @@ catlist.contextMenuEntries = function(panelId, labelId) {
[ theUILang.tegMenuDelete, "theWebUI.extTegDelete()"]
] : false;
}
return catlist.contextMenuEntries(panelId, labelId);
return plugin.contextMenuEntries(panelId, labelId);
}

plugin.createMenu = theWebUI.createMenu;
Expand All @@ -465,7 +465,8 @@ catlist.refreshPanel.psearch = (attribs) => psearchEntries(attribs).concat(Objec
...attribs.get(tegId),
text: teg.val,
icon: `url:./plugins/extsearch/images/${teg.eng === 'all' ? 'search' : teg.eng}.png`,
count: String(teg.data.filter(d => !d.deleted).length)
count: String(teg.data.filter(d => !d.deleted).length),
selected: catlist.isLabelIdSelected("psearch", tegId),
}
]));

Expand Down
4 changes: 2 additions & 2 deletions plugins/rss/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ theWebUI.RSSManager = function()
}

plugin.contextMenuTable = theWebUI.contextMenuTable;
theWebUI.contextMenuTable = function(panelId, el) {
theWebUI.contextMenuTable = function(panelId, labelId) {
return panelId === 'prss' ?
theWebUI.getTable('rss')
: plugin.contextMenuTable.call(theWebUI, panelId, el);
: plugin.contextMenuTable.call(theWebUI, panelId, labelId);
},

plugin.contextMenuEntries = catlist.contextMenuEntries.bind(catlist);
Expand Down