diff --git a/js/ui/components/EditModal.js b/js/ui/components/EditModal.js index 098a62f1..a76f0611 100644 --- a/js/ui/components/EditModal.js +++ b/js/ui/components/EditModal.js @@ -888,7 +888,7 @@ export class EditModal { } } - submit() { + async submit() { if (this.pendingSubmit) { return; } @@ -1076,6 +1076,34 @@ export class EditModal { return; } + // Auto-derive a webseed torrent when the URL was changed to an external link + // with no magnet, so an edited external URL keeps the P2P benefit (magnet + // ws=url). Best-effort + size-capped; on CORS / too-large / any error it stays + // URL-only. Runs before the magnet normalization below so the derived magnet's + // ws/xs are extracted the same way a pasted magnet's are. (Hosting the tiny + // .torrent (xs=) on the edit path needs credential plumbing — a follow-up.) + if ( + urlWasEdited && + finalUrl && + !finalMagnet && + typeof this.mediaUploader?.deriveTorrentForExternalUrl === "function" + ) { + try { + const derived = await this.mediaUploader.deriveTorrentForExternalUrl( + finalUrl, + {}, + ); + if (derived?.magnet) { + finalMagnet = derived.magnet; + } + } catch (error) { + devLogger.warn( + "[EditModal] External URL webseed derivation skipped:", + error?.message || error, + ); + } + } + if (finalMagnet) { // When the web seed list was manually edited, replace the magnet's full // ws= set with exactly what's in the field — this is what makes removal