Commit 2784739b authored by Alain Takoudjou's avatar Alain Takoudjou

erp5_web_mynij_search: remove seeded torrent is seed was disabled on index source

parent 7a20dbff
......@@ -376,6 +376,7 @@
.onLoop(function () {
var gadget = this,
container = document.getElementById('seedactivities'),
seed_element,
info,
element,
i,
......@@ -383,8 +384,14 @@
if (!container)
return;
info = container.querySelector('h2.info')
seed_element = container.querySelector('.torrent-seed');
key_list = Object.keys(gadget.state.seed_index);
if (!key_list.length) {
if (!info && seed_element) {
info = document.createElement('h2');
info.className = 'info';
seed_element.appendChild(info);
}
info.innerText = "There is no torrent peer seeding!";
}
for (i = 0; i < key_list.length; i += 1) {
......@@ -514,11 +521,12 @@
function seedTorrent() {
return gadget.jio_allDocs({
query: 'portal_type: "Mynij Search Collection"',
"select_list": ["seed"]
"select_list": ["title", "seed"]
})
.push(function (result_list) {
var i,
promise_list = [];
promise_list = [],
torrent_id;
console.log(result_list);
for (i = 0; i < result_list.data.rows.length; i += 1) {
let item = result_list.data.rows[i];
......@@ -527,6 +535,17 @@
gadget.state.seed_index[item.id] = {};
promise_list.push(gadget.seedIndex(item.id));
console.log("call seed to " + item.id);
} else if (gadget.state.seed_index.hasOwnProperty(item.id)) {
// remove torrent seed
torrent_id = gadget.state.seed_index[item.id].infoHash
gadget.state.seed_index[item.id].destroy(function () {
var element = torrentHtmlElement(torrent_id);
console.log("Torrent of '" + item.value.title +
"' destroyed...");
if (element)
element.remove();
});
delete gadget.state.seed_index[item.id];
}
}
return RSVP.all(promise_list);
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.27539.50696.19524</string> </value>
<value> <string>989.30643.58517.13209</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1610982586.19</float>
<float>1611167690.79</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment