Merge pull request #1142 from PR0M3TH3AN/custom-upload-improvements-8548800607217906810

Improve Custom Video Upload UX and Magnet Handling
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-07 21:25:20 -05:00
commit 52d7311400
3 files changed
+29 -11

No files matched your search

+13 -4
View File
@@ -36,11 +36,20 @@ export function normalizeAndAugmentMagnet(rawValue, { ws = "", xs = "" } = {}) {
ensureTorrentHint(params, normalizedXs, { requireHttp: false });
}
const rawWs = typeof ws === "string" ? ws.trim() : "";
if (rawWs) {
const formattedWs = formatAbsoluteUrl(rawWs);
const wsList = Array.isArray(ws)
? ws
: typeof ws === "string"
? [ws]
: [];
if (wsList.length > 0) {
const allowHttpSeed = resolveAppProtocol() === "http:";
ensureWebSeeds(params, formattedWs, {
const formattedList = wsList
.map((item) => (typeof item === "string" ? item.trim() : ""))
.filter((item) => item)
.map((item) => formatAbsoluteUrl(item));
ensureWebSeeds(params, formattedList, {
allowHttp: allowHttpSeed,
allowUnparsed: true,
});
+9 -1
View File
@@ -379,8 +379,16 @@ export function normalizeVideoNotePayload(input) {
}
if (legacyFormData.magnet) {
const wsList = [];
if (ws) {
wsList.push(ws);
}
if (legacyFormData.url && /^https?:\/\//i.test(legacyFormData.url)) {
wsList.push(legacyFormData.url);
}
const normalizedMagnet = normalizeAndAugmentMagnet(legacyFormData.magnet, {
ws,
ws: wsList,
xs,
});
legacyFormData.magnet = normalizedMagnet;
+7 -6
View File
@@ -744,10 +744,16 @@ export class UploadModal {
);
}
const nip71Metadata = this.nip71FormManager.collectSection("custom");
if (nip71Metadata) {
rawPayload.nip71 = nip71Metadata;
}
const hasDirectUrl = typeof rawPayload.url === "string" && rawPayload.url.trim().length > 0;
const hasMagnet = typeof rawPayload.magnet === "string" && rawPayload.magnet.trim().length > 0;
const hasImetaUrl = nip71Metadata?.imeta?.some((v) => v.url && v.url.trim().length > 0);
if (!hasDirectUrl && hasMagnet) {
if (!hasDirectUrl && !hasImetaUrl && hasMagnet) {
const confirmed = typeof window !== "undefined" && window.confirm
? window.confirm("You are uploading with a magnet link only.\n\nSince this video is not hosted on a server, it will only be playable as long as you (or others) continue seeding it.\n\nDo you want to proceed?")
: true;
@@ -758,11 +764,6 @@ export class UploadModal {
}
}
const nip71Metadata = this.nip71FormManager.collectSection("custom");
if (nip71Metadata) {
rawPayload.nip71 = nip71Metadata;
}
const { payload, errors } = normalizeVideoNotePayload(rawPayload);
if (errors.length) {