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.
This commit is contained in:
google-labs-jules[bot] committed 2026-01-08 01:24:31 +00:00
1 parent cc130ae513
commit c934e243c3
2 files changed
+19 -2

No files matched your search

+5 -2
View File
@@ -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,
};
+14
View File
@@ -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;