From c934e243c377693f406c9c12a85d409f6a65bb38 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 8 Jan 2026 01:24:31 +0000 Subject: [PATCH] feat: warn on magnet-only uploads and make video fetch limit configurable - Add a confirmation dialog in `UploadModal.js` when a user uploads a video with only a magnet link to warn about potential data loss. - Replace the hardcoded limit of 300 in `NostrClient.fetchVideos` with a configurable limit that respects `DEFAULT_VIDEO_REQUEST_LIMIT` and `MAX_VIDEO_REQUEST_LIMIT`, improving client-side scalability. --- js/nostr/client.js | 7 +++++-- js/ui/components/UploadModal.js | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/js/nostr/client.js b/js/nostr/client.js index 73f02b36..4790e0bd 100644 --- a/js/nostr/client.js +++ b/js/nostr/client.js @@ -5856,11 +5856,14 @@ export class NostrClient { /** * fetchVideos => old approach */ - async fetchVideos() { + async fetchVideos(options = {}) { + const requestedLimit = Number(options?.limit); + const resolvedLimit = this.clampVideoRequestLimit(requestedLimit, DEFAULT_VIDEO_REQUEST_LIMIT); + const filter = { kinds: [30078], "#t": ["video"], - limit: 300, + limit: resolvedLimit, since: 0, }; diff --git a/js/ui/components/UploadModal.js b/js/ui/components/UploadModal.js index 544bb25f..fc0cf4b8 100644 --- a/js/ui/components/UploadModal.js +++ b/js/ui/components/UploadModal.js @@ -744,6 +744,20 @@ export class UploadModal { ); } + const hasDirectUrl = typeof rawPayload.url === "string" && rawPayload.url.trim().length > 0; + const hasMagnet = typeof rawPayload.magnet === "string" && rawPayload.magnet.trim().length > 0; + + if (!hasDirectUrl && 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; + + if (!confirmed) { + this.updateCustomSubmitButtonState(); + return; + } + } + const nip71Metadata = this.nip71FormManager.collectSection("custom"); if (nip71Metadata) { rawPayload.nip71 = nip71Metadata;