From 7cf334de8b78656746e670f5366b8ae32ee9154a Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 26 Oct 2025 22:18:10 -0400 Subject: [PATCH] update --- js/app.js | 99 ++++++++++++++++++++++++--------- js/index.js | 8 +++ js/ui/components/UploadModal.js | 2 +- 3 files changed, 83 insertions(+), 26 deletions(-) diff --git a/js/app.js b/js/app.js index 9cdfb089..70c33279 100644 --- a/js/app.js +++ b/js/app.js @@ -283,6 +283,7 @@ class Application { this.modalCommentLimit = 40; this.modalCommentLoadPromise = null; this.modalCommentPublishPromise = null; + this.uploadSubmitPromise = null; this.pendingModeratedPlayback = null; this.lastIdentityRefreshPromise = null; this.profileIdentityController = new ProfileIdentityController({ @@ -4639,31 +4640,57 @@ class Application { * Actually handle the upload form submission. */ async handleUploadSubmitEvent(event) { + if (this.uploadSubmitPromise) { + devLogger.warn( + "[Application] Ignoring upload submit while a publish is already in progress.", + ); + this.showStatus( + "Please wait for your current video to finish publishing before sharing another.", + { autoHideMs: 6000, showSpinner: false }, + ); + if (this.uploadModal?.updateCustomSubmitButtonState) { + this.uploadModal.updateCustomSubmitButtonState(); + } + return; + } + const payload = event?.detail?.payload || {}; + const submitPromise = (async () => { + try { + const publishResult = await this.authService.handleUploadSubmit(payload, { + publish: (data) => + this.publishVideoNote(data, { + onSuccess: () => { + if (this.uploadModal?.resetCustomForm) { + this.uploadModal.resetCustomForm(); + } + }, + }), + }); + if (!publishResult && this.uploadModal?.cancelCustomSubmitCooldown) { + this.uploadModal.cancelCustomSubmitCooldown(); + } + } catch (error) { + if (this.uploadModal?.cancelCustomSubmitCooldown) { + this.uploadModal.cancelCustomSubmitCooldown(); + } + const message = this.describeLoginError( + error, + "Login required to publish videos.", + ); + this.showError(message); + } + })(); + + this.uploadSubmitPromise = submitPromise; + try { - const publishResult = await this.authService.handleUploadSubmit(payload, { - publish: (data) => - this.publishVideoNote(data, { - onSuccess: () => { - if (this.uploadModal?.resetCustomForm) { - this.uploadModal.resetCustomForm(); - } - }, - }), - }); - if (!publishResult && this.uploadModal?.cancelCustomSubmitCooldown) { - this.uploadModal.cancelCustomSubmitCooldown(); + await submitPromise; + } finally { + if (this.uploadSubmitPromise === submitPromise) { + this.uploadSubmitPromise = null; } - } catch (error) { - if (this.uploadModal?.cancelCustomSubmitCooldown) { - this.uploadModal.cancelCustomSubmitCooldown(); - } - const message = this.describeLoginError( - error, - "Login required to publish videos.", - ); - this.showError(message); } } @@ -5346,8 +5373,9 @@ class Application { this.profileButton.removeAttribute("hidden"); } - if (this.subscriptionsLink) { - this.subscriptionsLink.classList.remove("hidden"); + const subscriptionsLink = this.resolveSubscriptionsLink(); + if (subscriptionsLink) { + subscriptionsLink.classList.remove("hidden"); } } @@ -5379,8 +5407,9 @@ class Application { this.profileButton.setAttribute("hidden", ""); } - if (this.subscriptionsLink) { - this.subscriptionsLink.classList.add("hidden"); + const subscriptionsLink = this.resolveSubscriptionsLink(); + if (subscriptionsLink) { + subscriptionsLink.classList.add("hidden"); } } @@ -5392,6 +5421,26 @@ class Application { } } + resolveSubscriptionsLink() { + if (this.subscriptionsLink instanceof HTMLElement) { + return this.subscriptionsLink; + } + + const linkCandidate = document.getElementById("subscriptionsLink"); + if (linkCandidate instanceof HTMLElement) { + this.subscriptionsLink = linkCandidate; + return this.subscriptionsLink; + } + + this.subscriptionsLink = null; + return null; + } + + hydrateSidebarNavigation() { + this.resolveSubscriptionsLink(); + this.syncAuthUiState(); + } + maybeShowExperimentalLoginWarning(provider) { const normalizedProvider = typeof provider === "string" ? provider.trim().toLowerCase() : ""; diff --git a/js/index.js b/js/index.js index 42167448..c9d5f167 100644 --- a/js/index.js +++ b/js/index.js @@ -620,6 +620,14 @@ async function bootstrapInterface() { await loadSidebar("components/sidebar.html", "sidebarContainer"); devLogger.log("Sidebar loaded."); + if (application && typeof application.hydrateSidebarNavigation === "function") { + try { + application.hydrateSidebarNavigation(); + } catch (error) { + devLogger.warn("[Interface] Failed to hydrate sidebar navigation:", error); + } + } + bindOptionalExternalLink({ selector: "[data-blog-link]", url: BLOG_URL, diff --git a/js/ui/components/UploadModal.js b/js/ui/components/UploadModal.js index 65350aca..544bb25f 100644 --- a/js/ui/components/UploadModal.js +++ b/js/ui/components/UploadModal.js @@ -397,7 +397,6 @@ export class UploadModal { this.updateCustomSubmitButtonState(); return; } - this.startCustomSubmitCooldown(); this.handleCustomSubmit(); }); } @@ -758,6 +757,7 @@ export class UploadModal { return; } + this.startCustomSubmitCooldown(); this.emit("upload:submit", { payload }); }