diff --git a/components/upload-modal.html b/components/upload-modal.html
index 3cf5a035..cf8fae25 100644
--- a/components/upload-modal.html
+++ b/components/upload-modal.html
@@ -153,6 +153,11 @@
+
+
Provider
diff --git a/js/ui/components/UploadModal.js b/js/ui/components/UploadModal.js
index 28d45373..9a1714ed 100644
--- a/js/ui/components/UploadModal.js
+++ b/js/ui/components/UploadModal.js
@@ -31,6 +31,8 @@ import {
ensureStorageUnlockedForUpload,
resetThumbnailPicker,
promptStoredNsecUnlock,
+ pickTargetConnection,
+ renderConnectionPicker,
} from "./uploadModalStorageUnlock.js";
const INFO_HASH_PATTERN = /^[a-f0-9]{40}$/;
@@ -116,6 +118,8 @@ export class UploadModal {
this.activeProvider = null;
this.isStorageUnlocked = false;
this.storageConfigured = false;
+ // #44: per-modal upload-destination override (null = account default).
+ this.selectedConnectionId = null;
// Upload State
this.videoUploadState = {
@@ -247,6 +251,7 @@ export class UploadModal {
progress: $("#upload-progress-container"),
thumbnailProgress: $("#thumbnail-progress-container"),
results: $("#upload-results-container"),
+ connectionPicker: $("#storage-connection-picker"),
};
this.storageViews = {
@@ -274,6 +279,9 @@ export class UploadModal {
// Progress
progress: $("#input-progress"),
thumbnailProgress: $("#thumbnail-progress"),
+
+ // #44: upload-destination picker
+ storageConnection: $("#select-storage-connection"),
};
// Results (Generated Links)
@@ -334,6 +342,14 @@ export class UploadModal {
this.toggles.storageUnlock.addEventListener("click", () => this.handleUnlock());
}
+ if (this.inputs.storageConnection) {
+ // #44: switching the destination re-resolves summary + credentials.
+ this.inputs.storageConnection.addEventListener("change", () => {
+ this.selectedConnectionId = this.inputs.storageConnection.value || null;
+ void this.loadFromStorage();
+ });
+ }
+
// Manage Storage
if (this.toggles.manageStorage) {
this.toggles.manageStorage.addEventListener("click", () => {
@@ -910,9 +926,9 @@ export class UploadModal {
try {
const connections = await this.storageService.listConnections(pubkey);
- // Prefer default connection
- const defaultConn = connections.find(c => c.meta?.defaultForUploads);
- const targetConn = defaultConn || connections[0];
+ // #44: a per-modal selection wins over the account default.
+ const { targetConn, defaultConn } = pickTargetConnection(this, connections);
+ renderConnectionPicker(this, connections, targetConn, defaultConn);
if (targetConn) {
this.storageConfigured = true;
diff --git a/js/ui/components/uploadModalStorageUnlock.js b/js/ui/components/uploadModalStorageUnlock.js
index f5b4a1f7..8915fb5b 100644
--- a/js/ui/components/uploadModalStorageUnlock.js
+++ b/js/ui/components/uploadModalStorageUnlock.js
@@ -1,9 +1,10 @@
// js/ui/components/uploadModalStorageUnlock.js
//
-// Storage-unlock glue for the Upload modal (#36 / #56), kept out of
-// UploadModal.js to stay within its file-size budget. Every function operates
-// on the UploadModal instance (`modal`); UploadModal exposes them as thin
-// prototype delegates so callers and tests keep using the instance methods.
+// Storage glue for the Upload modal (#36 / #56 unlock + #44 connection
+// picker), kept out of UploadModal.js to stay within its file-size budget.
+// Every function operates on the UploadModal instance (`modal`); UploadModal
+// exposes them as thin prototype delegates so callers and tests keep using
+// the instance methods.
import { devLogger, userLogger } from "../../utils/logger.js";
@@ -67,6 +68,52 @@ export function resetThumbnailPicker(modal) {
}
}
+// #44: resolve which configured connection this upload targets. A per-modal
+// selection wins; a stale selection (connection deleted meanwhile) is reset;
+// otherwise the account default, then the first configured connection.
+export function pickTargetConnection(modal, connections) {
+ const list = Array.isArray(connections) ? connections : [];
+ const defaultConn = list.find((conn) => conn?.meta?.defaultForUploads) || null;
+ if (modal.selectedConnectionId) {
+ const selected = list.find((conn) => conn?.id === modal.selectedConnectionId);
+ if (selected) {
+ return { targetConn: selected, defaultConn };
+ }
+ modal.selectedConnectionId = null;
+ }
+ return { targetConn: defaultConn || list[0] || null, defaultConn };
+}
+
+// #44: render the "Upload destination"