aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAjay <[email protected]>2024-02-01 13:31:19 -0500
committerAjay <[email protected]>2024-02-01 13:31:19 -0500
commite0fe0fad671364cfb94df3bde5a9a17b23b25003 (patch)
treefbb4a912d5e82081e3df1035932983810cd774af /src
parentc0bc068a18e0423f69a987c5bcf37bd5b42f1ad7 (diff)
downloadSponsorBlock-e0fe0fad671364cfb94df3bde5a9a17b23b25003.tar.gz
SponsorBlock-e0fe0fad671364cfb94df3bde5a9a17b23b25003.zip
Don't close submission menu if submission didn't go through
Fxies submission menu closing for warning about previewing a segment
Diffstat (limited to 'src')
-rw-r--r--src/components/SubmissionNoticeComponent.tsx10
-rw-r--r--src/content.ts12
-rw-r--r--src/render/SubmissionNotice.tsx4
3 files changed, 16 insertions, 10 deletions
diff --git a/src/components/SubmissionNoticeComponent.tsx b/src/components/SubmissionNoticeComponent.tsx
index 7ddc3e0e..2cf394f1 100644
--- a/src/components/SubmissionNoticeComponent.tsx
+++ b/src/components/SubmissionNoticeComponent.tsx
@@ -14,7 +14,7 @@ export interface SubmissionNoticeProps {
// Contains functions and variables from the content script needed by the skip notice
contentContainer: ContentContainer;
- callback: () => unknown;
+ callback: () => Promise<boolean>;
closeListener: () => void;
}
@@ -239,9 +239,11 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
}
}
- this.props.callback();
-
- this.cancel();
+ this.props.callback().then((success) => {
+ if (success) {
+ this.cancel();
+ }
+ });
}
sortSegments(): void {
diff --git a/src/content.ts b/src/content.ts
index 51b96aeb..ee328d92 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -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
diff --git a/src/render/SubmissionNotice.tsx b/src/render/SubmissionNotice.tsx
index 5e9fbfbd..c0159cc0 100644
--- a/src/render/SubmissionNotice.tsx
+++ b/src/render/SubmissionNotice.tsx
@@ -11,7 +11,7 @@ class SubmissionNotice {
// Contains functions and variables from the content script needed by the skip notice
contentContainer: () => unknown;
- callback: () => unknown;
+ callback: () => Promise<boolean>;
noticeRef: React.MutableRefObject<SubmissionNoticeComponent>;
@@ -19,7 +19,7 @@ class SubmissionNotice {
root: Root;
- constructor(contentContainer: ContentContainer, callback: () => unknown) {
+ constructor(contentContainer: ContentContainer, callback: () => Promise<boolean>) {
this.noticeRef = React.createRef();
this.contentContainer = contentContainer;