Fox sorting and magnet links
Magnet button stays disabled
This commit is contained in:
@@ -80,14 +80,16 @@ class trdom_servermanager extends EventTarget {
|
||||
let initControls = {};
|
||||
let initHash = e.detail.torrentHash;
|
||||
for (const [srv, server] of Object.entries(this.#servers)) {
|
||||
let control = server == e.detail.serverObject ? e.detail.torrentControl : new trdom_torrentcontrol(initHash, server, null, this.#logcb);
|
||||
let control = server == e.detail.serverObject ? e.detail.torrentControl : new trdom_torrentcontrol(initHash, server, {magnetLink: e.detail.torrentControl.magnet}, this.#logcb);
|
||||
//server.addControl(control);
|
||||
initControls[srv] = control;
|
||||
}
|
||||
let initEvent = new CustomEvent('torrent-created', {
|
||||
detail: {
|
||||
torrentHash: initHash,
|
||||
torrentControls: initControls
|
||||
torrentControls: initControls,
|
||||
torrentName: e.detail.torrentControl.name,
|
||||
magnetLink: e.detail.torrentControl.magnet
|
||||
}
|
||||
});
|
||||
this.dispatchEvent(initEvent);
|
||||
|
||||
@@ -18,7 +18,20 @@ class trdom_torrentcontrol extends EventTarget {
|
||||
|
||||
#data;
|
||||
get exists() {
|
||||
return this.#data != null;
|
||||
return this.#data != null && this.#data.name != null;
|
||||
}
|
||||
get name() {
|
||||
return this.exists ? this.#data.name : this.#hash;
|
||||
}
|
||||
get magnet() {
|
||||
return this.#data != null ? this.#data.magnetLink : null;
|
||||
}
|
||||
set magnet(value) {
|
||||
if (this.#data == null) {
|
||||
this.#data = {};
|
||||
}
|
||||
this.#data.magnetLink = value;
|
||||
this.updateDOM();
|
||||
}
|
||||
|
||||
updateDOM() {
|
||||
|
||||
@@ -41,7 +41,8 @@ class trdom_torrentmanager extends EventTarget {
|
||||
case 'torrent-created':
|
||||
let initHash = e.detail.torrentHash;
|
||||
if (this.#torrentDB[initHash] == null) {
|
||||
let torrentCreated = new trtorrent(initHash);
|
||||
let torrentCreated = new trtorrent(initHash, e.detail.magnetLink);
|
||||
torrentCreated.name = e.detail.torrentName;
|
||||
this.#torrentDB[initHash] = torrentCreated;
|
||||
torrentCreated.addEventListener('torrent-renamed', this);
|
||||
this.#putToPlace(torrentCreated);
|
||||
@@ -61,7 +62,7 @@ class trdom_torrentmanager extends EventTarget {
|
||||
case 'torrentserver-added':
|
||||
let addedServer = e.detail.serverObject;
|
||||
for (const [hash, torrent] of Object.entries(this.#torrentDB)) {
|
||||
torrent.addControl(addedServer.name, new trdom_torrentcontrol(hash, addedServer, null, this.#logcb))
|
||||
torrent.addControl(addedServer.name, new trdom_torrentcontrol(hash, addedServer, {magnetLink: torrent.magnet}, this.#logcb))
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -105,7 +105,7 @@ class trserver extends EventTarget {
|
||||
if (!this.#isOnline) {
|
||||
this.#log(4, 'Server API connection estabilished');
|
||||
this.#isOnline = true;
|
||||
//this.#forceUpdateTorrents();
|
||||
this.#forceUpdateTorrents();
|
||||
}
|
||||
//request.response = JSON.parse(e.target.responseText);
|
||||
if (request.success != null) {
|
||||
|
||||
@@ -16,6 +16,10 @@ class trtorrent extends EventTarget {
|
||||
nukeChildren(this.element.element_name);
|
||||
this.element.element_name.appendChild(document.createTextNode(this.name));
|
||||
}
|
||||
#magnetLink;
|
||||
get magnet() {
|
||||
return this.#magnetLink;
|
||||
}
|
||||
|
||||
#serverControls = {};
|
||||
addControl(srv, control) {
|
||||
@@ -61,9 +65,10 @@ class trtorrent extends EventTarget {
|
||||
}
|
||||
}
|
||||
|
||||
constructor(hash) {
|
||||
constructor(hash, magnet = null) {
|
||||
super();
|
||||
this.#hash = hash;
|
||||
this.#magnetLink = magnet;
|
||||
|
||||
// set up DOM structure
|
||||
let element_name = document.createElement('div');
|
||||
|
||||
Reference in New Issue
Block a user