Don't close submission menu if submission didn't go through

Fxies submission menu closing for warning about previewing a segment
This commit is contained in:
Ajay
2024-02-01 13:31:19 -05:00
parent c0bc068a18
commit e0fe0fad67
3 changed files with 16 additions and 10 deletions

View File

@@ -2265,13 +2265,13 @@ function submitSegments() {
//send the message to the background js
//called after all the checks have been made that it's okay to do so
async function sendSubmitMessage() {
async function sendSubmitMessage(): Promise<boolean> {
// check if all segments are full video
const onlyFullVideo = sponsorTimesSubmitting.every((segment) => segment.actionType === ActionType.Full);
// Block if submitting on a running livestream or premiere
if (!onlyFullVideo && (getIsLivePremiere() || isVisible(document.querySelector(".ytp-live-badge")))) {
alert(chrome.i18n.getMessage("liveOrPremiere"));
return;
return false;
}
if (!previewedSegment
@@ -2279,7 +2279,7 @@ async function sendSubmitMessage() {
[ActionType.Full, ActionType.Chapter, ActionType.Poi].includes(segment.actionType)
|| segment.segment[1] >= getVideo()?.duration)) {
alert(`${chrome.i18n.getMessage("previewSegmentRequired")} ${keybindToString(Config.config.previewKeybind)}`);
return;
return false;
}
// Add loading animation
@@ -2305,7 +2305,7 @@ async function sendSubmitMessage() {
const confirmShort = chrome.i18n.getMessage("shortCheck") + "\n\n" +
getSegmentsMessage(sponsorTimesSubmitting);
if(!confirm(confirmShort)) return;
if(!confirm(confirmShort)) return false;
}
}
}
@@ -2355,6 +2355,8 @@ async function sendSubmitMessage() {
if (fullVideoSegment) {
categoryPill?.setSegment(fullVideoSegment);
}
return true;
} else {
// Show that the upload failed
playerButtons.submit.button.style.animation = "unset";
@@ -2366,6 +2368,8 @@ async function sendSubmitMessage() {
alert(getErrorMessage(response.status, response.responseText));
}
}
return false;
}
//get the message that visually displays the video times