mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-11 23:32:31 +00:00
Merge pull request #958 from PR0M3TH3AN/codex/fix-video-publish-function-to-prevent-duplicates
Prevent duplicate video publishes
This commit is contained in:
2 files changed
+49
-22
No files matched your search
@@ -283,6 +283,7 @@ class Application {
|
|||||||
this.modalCommentLimit = 40;
|
this.modalCommentLimit = 40;
|
||||||
this.modalCommentLoadPromise = null;
|
this.modalCommentLoadPromise = null;
|
||||||
this.modalCommentPublishPromise = null;
|
this.modalCommentPublishPromise = null;
|
||||||
|
this.uploadSubmitPromise = null;
|
||||||
this.pendingModeratedPlayback = null;
|
this.pendingModeratedPlayback = null;
|
||||||
this.lastIdentityRefreshPromise = null;
|
this.lastIdentityRefreshPromise = null;
|
||||||
this.profileIdentityController = new ProfileIdentityController({
|
this.profileIdentityController = new ProfileIdentityController({
|
||||||
@@ -4639,31 +4640,57 @@ class Application {
|
|||||||
* Actually handle the upload form submission.
|
* Actually handle the upload form submission.
|
||||||
*/
|
*/
|
||||||
async handleUploadSubmitEvent(event) {
|
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 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 {
|
try {
|
||||||
const publishResult = await this.authService.handleUploadSubmit(payload, {
|
await submitPromise;
|
||||||
publish: (data) =>
|
} finally {
|
||||||
this.publishVideoNote(data, {
|
if (this.uploadSubmitPromise === submitPromise) {
|
||||||
onSuccess: () => {
|
this.uploadSubmitPromise = null;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -397,7 +397,6 @@ export class UploadModal {
|
|||||||
this.updateCustomSubmitButtonState();
|
this.updateCustomSubmitButtonState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.startCustomSubmitCooldown();
|
|
||||||
this.handleCustomSubmit();
|
this.handleCustomSubmit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -758,6 +757,7 @@ export class UploadModal {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.startCustomSubmitCooldown();
|
||||||
this.emit("upload:submit", { payload });
|
this.emit("upload:submit", { payload });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user